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...

local Button = script.Parent
    local Door4 = game:GetService("Workspace"):WaitForChild("Door4")
    Door4.Anchored = true

    Button.MouseButton1Click:Connect(function()
    if Door4.CanCollide then
    Door4.CanCollide = not Door4.CanCollide
    elseif not Door4.CanCollide then
    Door4.CanCollide = true
    end
    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...

local button = script.Parent
local door = workspace.Door4
door.Anchored = true
local debounce = true
button.MouseButton1Click:Connect(function()
    if debounce == true then
        door.CanCollide = false
        debounce = false
    else
        door.CanCollide = true
        debounce = true
    end
end)

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

Ad

Answer this question