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

Help with a key door tool?

It works in playtest but not online. I'm not sure what's wrong and output tells me nothing.

bin = script.Parent

function onButton1Down(mouse)

    local hit = mouse.Target
    if (hit == nil) then return end
    if (hit.Name == "SilverDoor2") then
    hit.Transparency = 0.8
    hit.CanCollide = false
    wait(2)
    hit.CanCollide = true
    hit.Transparency = 0

    end
end

function onSelected(mouse)
    print("Action Tool Selected")

    mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end

bin.Selected:connect(onSelected)

2 answers

Add wait() to the beginning of the script. Scripts that run locally or are based on client-sided objects should be careful to wait that everything has loaded, and for hopperbins this usually fixes it.

1 comment

0

Sadly, this doesn't work. The function onSelected does work. But onButton1Down does not work.

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