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

This key script will work in test mode but not when you actually play the game. Anyone know why?

This key script is a local script which is placed in replicated first. It works perfectly in test mode but when you actually join it doesn't work. Anybody know why and how to fix it?

game.workspace.BDoor1.Touched:connect(function(hit)
    if hit.parent.name == "Key" and hit.Parent.ClassName == "Tool" then
       game.workspace.BDoor1.Transparency = 1
       game.workspace.BDoor1.CanCollide = false
    end
end)

2 answers

✓ Accepted answer
game.Workspace.BDoor1.Touched:connect(function(hit)
    if hit.Parent.Name == "Key" and hit.Parent:IsA("Tool") then
       game.Workspace.BDoor1.Transparency = 1
       game.Workspace.BDoor1.CanCollide = false
    end
end)

With correct capitalization and little changes.

2 comments

0

Damn, you just barely got there first haha. Upvoted.

0

haha

Your first issue is that the local script's parent is ReplicatedFirst. Try making it a script and placing this in the ServerScriptService -

game.Workspace.BDoor1.Touched:Connect(function(hit)
    if hit.Parent.Name == "Key" and hit.Parent:IsA("Tool") then
       game.Workspace.BDoor1.Transparency = 1
       game.Workspace.BDoor1.CanCollide = false
    end
end)

Don't forget to accept an answer! :)

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