The goal of this is to make it so that if you're in a zone, it'll give you an option to open the door by pressing Q. This works fine on Studio, but FAILS on the game. This is my script:
S1 = script.Parent.Sensors.S1
S2 = script.Parent.Sensors.S2
Door = script.Parent.Door
ST = script.Parent.Sensors.SensorTop
SF = script.Parent.Sensors.FloorSensor
_G.ActionGUIs = game.ReplicatedStorage.ActionGUIs
function Animate()
end
EntranceDoorDebounce = false
_G["OpenEntranceDoor"] = function ()
if not EntranceDoorDebounce then
EntranceDoorDebounce = true
Door.BodyVelocity.velocity = Vector3.new(0, 2,0)
ST.Touched:connect(function (hit)
if hit.Name == "Door" then
wait(3)
hit.BodyVelocity.velocity = Vector3.new(0, -2, 0)
SF.Touched:connect(function (hit)
if hit.Name == "Door" then
EntranceDoorDebounce = false
end
end)
end
end)
end
end
function DealHotkey(hit)
if not hit.Parent:FindFirstChild("Humanoid") then return end
local Player = hit.Parent
Player.Actions.Action.CanDoAction.Value = true
Player.Actions.Action.ActionType.Value = "EntranceDoor"
local newGUI = _G.ActionGUIs.OpenDoorGUI:Clone()
newGUI.Parent = game.Players:FindFirstChild(Player.Name).PlayerGui
end
function DealHotkey2(hit)
if not hit.Parent:FindFirstChild("Humanoid") then return end
local Player = hit.Parent
Player.Actions.Action.CanDoAction.Value = false
Player.Actions.Action.ActionType.Value = ""
local datGUI = game.Players:FindFirstChild(Player.Name)
if not datGUI.PlayerGui:FindFirstChild("OpenDoorGUI") then return end
datGUI.PlayerGui.OpenDoorGUI:Destroy()
end
S1.Touched:connect(DealHotkey)
S2.Touched:connect(DealHotkey)
S1.TouchEnded:connect(DealHotkey2)
S2.TouchEnded:connect(DealHotkey2)
And the script that calls the actual door movement is located in the player, this is it:
local player = game.Players.LocalPlayer
local m = player:GetMouse()
m.KeyDown:connect(function (key)
if key == "q" then
if script.Action.CanDoAction.Value == false then return end
if script.Action.CanDoAction.Value == true then
local ActionType = script.Action.ActionType.Value
if ActionType == "EntranceDoor" then
_G.OpenEntranceDoor()
end
end
end
end)
If you know what I've stuffed up, please respond. Thanks in advance.

6 comments
Is your second script a LocalScript?
Yes, it is.
So is the Gui displaying and when you press Q nothing happens or is nothing displaying at all?
What is happening is EVERYTHING is working except the actual door movement. I'm also pretty certain it may not be reading the values correctly.
Hit detection works, taking the GUI away and putting it in works, but the only thing wrong is the moving of the door.
This is the game I'm using it in. http://www.roblox.com/--place?id=104698139