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

My script won't do anything at all and I don't understand why. Any ideas?

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

0

UserInputService only works in localscript

1 answer

✓ Accepted answer

First you posted the bottom script twice and UserinputService only works in localscript secondly

you are modifying the StarterGui, everything thats inside the startergui gets cloned into the PlayerGui of a player so if you modify something in StarterGui it will only show after the players dies so if you want the modify it instantly you have to modify the PlayerGui

the PlayerGui is part of the player. like this Player.PlayerGui

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