local TweenService = game:GetService("TweenService")
local Moving = false
local InRange = false
local door = script.Parent
local open = false
local tweeningInformation = TweenInfo.new(
0.5,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local doorOpen = {CFrame = door.CFrame + Vector3.new(-5.605)}
local tweendoorOpen = TweenService:Create(door,tweeningInformation,doorOpen)
local doorClose = {CFrame = door.CFrame + Vector3.new(-5.605) + Vector3.new(5.605)}
local tweendoorClose = TweenService:Create(door,tweeningInformation,doorClose)
script.Parent.Parent.TouchPart.Touched:Connect(function(player)
game.StarterGui.DoorsGUI.Frame.Visible = true
InRange = true
end)
script.Parent.Parent.TouchPart.TouchEnded:Connect(function(player)
game.StarterGui.DoorsGUI.Frame.Visible = false
InRange = false
end)
game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.E then
if InRange == true and Moving == false and open == false then
tweendoorOpen:Play()
open = true
Moving = true
wait(2)
Moving = false
end
end
end)
game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.E then
if InRange == true and Moving == false and open == true then
tweendoorClose:Play()
open = false
Moving = true
wait(2)
Moving = false
end
end
end)
That's the script, and when I walk up and touch my 'TouchPart' it does nothing at all. Why is this?

1 comment
UserInputService only works in localscript