generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Debuging Problems

Previous Thread :: Next Thread 
kingtut7 is not online. kingtut7
Joined: 22 Apr 2012
Total Posts: 8
17 Feb 2016 04:38 PM
I made this code but when I step on the Regen button nothing happens! Can someone help?

local buttonPressed = false

Regen_Button.Touched:connect(function(hit)
if not buttonPressed then
-- Is it not pressed?

local Regen_Button = game.Workspace["Regen_Button"]

function respawnCar()
print("Respawning...")
for _, object in pairs(game.Workspace:GetChildren()) do
print(object.Name)
if object.Name == "Race Car" then
print("Race Car Found")
end

end
local copyCar = game.ServerStorage["Race Car"]:Clone()
copyCar.Parent = game.Workspace
copyCar:MakeJoints()
end
end
end)
Report Abuse
Legoman654 is not online. Legoman654
Joined: 05 Jun 2008
Total Posts: 534
17 Feb 2016 04:42 PM
the function: respawnCar is never called. You just have it sitting in the Touched event. Functions do not trigger unless it called by respawnCar(). I would just take the function part out and remove an end and leave it as that.


Report Abuse
kingtut7 is not online. kingtut7
Joined: 22 Apr 2012
Total Posts: 8
17 Feb 2016 04:49 PM
I removed the function as you said but that didn't do anything.Here is the code now.


local buttonPressed = false

Regen_Button.Touched:connect(function(hit)
if not buttonPressed then
-- Is it not pressed?

local Regen_Button = game.Workspace["Regen_Button"]

for _, object in pairs(game.Workspace:GetChildren()) do
print(object.Name)
if object.Name == "Race Car" then
print("Race Car Found")
end

local copyCar = game.ServerStorage["Race Car"]:Clone()
copyCar.Parent = game.Workspace
copyCar:MakeJoints()
end
end
end)
Report Abuse
Legoman654 is not online. Legoman654
Joined: 05 Jun 2008
Total Posts: 534
17 Feb 2016 04:53 PM
Looks like you're defining the button inside of the event for the instance that doesn't exist. Define Regen_Button at the top outside of the event so it knows what part to trigger the event for:


local buttonPressed = false

local Regen_Button = game.Workspace["Regen_Button"]

Regen_Button.Touched:connect(function(hit)
if not buttonPressed then
for _, object in pairs(game.Workspace:GetChildren()) do
print(object.Name)
if object.Name == "Race Car" then
print("Race Car Found")
end
local copyCar = game.ServerStorage["Race Car"]:Clone()
copyCar.Parent = game.Workspace
copyCar:MakeJoints()
end
end
end)


Report Abuse
kingtut7 is not online. kingtut7
Joined: 22 Apr 2012
Total Posts: 8
17 Feb 2016 05:27 PM
But the Regen_Button is a part in my world not a variable. Whould that make a difference if I have to call it?
Report Abuse
Legoman654 is not online. Legoman654
Joined: 05 Jun 2008
Total Posts: 534
17 Feb 2016 05:35 PM
because the code does not know it is a part. If I had a part in game.Workspace, I can not just type out:

print(MyPart.Name)

I have to define what that part is:

MyPart = game.Workspace.Part

print(MyPart.Name)




Report Abuse
kingtut7 is not online. kingtut7
Joined: 22 Apr 2012
Total Posts: 8
17 Feb 2016 06:00 PM
Thanks for that but when I stepped on the button, it spawned in so many cars that Roblox Crashed. Do you know how to fix that?


Report Abuse
kingtut7 is not online. kingtut7
Joined: 22 Apr 2012
Total Posts: 8
17 Feb 2016 06:04 PM
local buttonPressed = false

Regen_Button = game.Workspace.Regen_Button

Regen_Button.Touched:connect(function(hit)
if not buttonPressed then
-- Is it not pressed?

local Regen_Button = game.Workspace["Regen_Button"]

for _, object in pairs(game.Workspace:GetChildren()) do
print(object.Name)
if object.Name == "Race Car" then
print("Race Car Found")
end

local copyCar = game.ServerStorage["Race Car"]:Clone()
copyCar.Parent = game.Workspace
copyCar:MakeJoints()
end
end
end)
Report Abuse
ShrekWillGetYou is not online. ShrekWillGetYou
Joined: 31 Oct 2010
Total Posts: 550
17 Feb 2016 06:57 PM
local Regen_Button = game.Workspace["Regen_Button"]
Is the part called "Regen Button" or "Regen_Button"


Report Abuse
ShrekWillGetYou is not online. ShrekWillGetYou
Joined: 31 Oct 2010
Total Posts: 550
17 Feb 2016 07:07 PM
The only reason it is spawning the vehicle more than once, is because you are hitting it more than once, therefore after it is hit you need to make cancollide = false

local buttonPressed = false

Regen_Button = game.Workspace.Regen_Button

Regen_Button.Touched:connect(function(hit)
if not buttonPressed then
Regen_Button.CanCollide = false

local Regen_Button = game.Workspace["Regen_Button"]

for _, object in pairs(game.Workspace:GetChildren()) do
print(object.Name)
if object.Name == "Race Car" then
print("Race Car Found")
end

local copyCar = game.ServerStorage["Race Car"]:Clone()
copyCar.Parent = game.Workspace
copyCar:MakeJoints()
end
end
end)


Report Abuse
kingtut7 is not online. kingtut7
Joined: 22 Apr 2012
Total Posts: 8
17 Feb 2016 07:16 PM
Doing that had the same effect. Here is what happens: I start the game and when I walk over to the button I touch it and the Output goes crazy and the game crashes.
Report Abuse
ShrekWillGetYou is not online. ShrekWillGetYou
Joined: 31 Oct 2010
Total Posts: 550
17 Feb 2016 07:18 PM
After you touched it once, did you then fall through the regen block?


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image