Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My script that multiple people told me that works works in studio but not in my games?

Asked by 6 years ago
Edited by Shawnyg 6 years ago

How and why does this not work, I got multiple people telling the same script to do what I'm doing and it doesn't work...

01local Button = script.Parent
02    local Door4 = game:GetService("Workspace"):WaitForChild("Door4")
03    Door4.Anchored = true
04 
05    Button.MouseButton1Click:Connect(function()
06    if Door4.CanCollide then
07    Door4.CanCollide = not Door4.CanCollide
08    elseif not Door4.CanCollide then
09    Door4.CanCollide = true
10    end
11    end)
0
Edit: Moved your script to your question. It's better practice to do so, as seeing a question having an answer already makes people not look at it. Shawnyg 4330 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Try this, I am unsure of what your game looks like so, here.. and by the way, for your if statement it doesn't return a value... which causes an error...

01local button = script.Parent
02local door = workspace.Door4
03door.Anchored = true
04local debounce = true
05button.MouseButton1Click:Connect(function()
06    if debounce == true then
07        door.CanCollide = false
08        debounce = false
09    else
10        door.CanCollide = true
11        debounce = true
12    end
13end)

Simple if statement fix, remember to answer the question if this script works, thanks

Ad

Answer this question