Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)


1 comment

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.

1 answer

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.