Here is the video: Dropbox - File Deleted - Simplify your life
Ah I see, it only does this when you come to close to the light switch?
Well you need to be close to interact with it. So kinda
Ok I think I found the solution. The script is registering every time the player presses E. lets say you have to hold down E for 5 seconds for the lights to turn off. If you hold E for 1 second and then release the E key then followed by pressing E again you will wait 4 seconds rather than 5, the reason being the script only end’s when you hold down the E key for 5 seconds.
local inputServ = game:GetService("UserInputService")
local tweenServ = game:GetService("TweenService")
local dist = 5
local text = script.Parent.Parent.Parent.e
local part = workspace.Thing
local lights = false
local canDo = false
local tweenInf = TweenInfo.new(1)
local tween = tweenServ:Create(script.Parent, tweenInf, {Size = UDim2.new(1, 0, 1, 0)})
local e = coroutine.create(function()
while wait() do
if (game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Position - part.Position).Magnitude < dist then
text.Visible = true
if lights then
text.Text = "<E> to turn off lights"
elseif lights == false then
text.Text = "<E> to turn on lights."
end
else
text.Visible = false
end
end
end)
local er = coroutine.create(function()
while wait() do
canDo = inputServ:IsKeyDown(Enum.KeyCode.E)
end
end)
coroutine.resume(e)
coroutine.resume(er)
local dbg = true
inputServ.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E and (game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Position - part.Position).Magnitude < dist then
dbg = true
game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Anchored = true
script.Parent.Parent.Visible = true
tween:Play()
wait(1)
if not dbg then
return
end
if canDo == false then
return
elseif canDo == true then
if lights and dbg then
print("Lights are now off")
workspace.Thing.PointLight.Enabled = false
lights = false
elseif not lights dbg then
print("Lights are now on")
workspace.Thing.PointLight.Enabled = true
lights = true
end
end
if not dbg then
return
end
tween:Cancel()
script.Parent.Parent.Visible = false
script.Parent.Size = UDim2.new(0, 0, 1, 0)
game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Anchored = false
end
end)
inputServ.InputEnded:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E then
dbg = false
tween:Cancel()
script.Parent.Parent.Visible = false
script.Parent.Size = UDim2.new(0, 0, 1, 0)
game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Anchored = false
end
end)
Give this a try?
elseif not lights dbg then
am I supposed to put and
before dbg
?
Edit: Yep
My bad… I just put it into a notepad and went from there, It would help if you could upload a studio file
Testing right now, please wait…
local inputServ = game:GetService("UserInputService")
local tweenServ = game:GetService("TweenService")
local dist = 5
local text = script.Parent.Parent.Parent.e
local part = workspace.Thing
local lights = false
local canDo = false
local tweenInf = TweenInfo.new(1)
local tween = tweenServ:Create(script.Parent, tweenInf, {Size = UDim2.new(1, 0, 1, 0)})
spawn(function()
while wait() do
if (game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Position - part.Position).Magnitude < dist then
text.Visible = true
if lights then
text.Text = "<E> to turn off lights"
elseif lights == false then
text.Text = "<E> to turn on lights."
end
else
text.Visible = false
end
end
end)
local LastStart = tick()
tween.Completed:Connect(function()
if tick() - LastStart > 0.6 then
print("Toggled Lights")
lights = not lights
workspace.Thing.PointLight.Enabled = not workspace.Thing.PointLight.Enabled
end
LastStart = tick()
end)
function Cancel()
script.Parent.Parent.Visible = false
tween:Cancel()
script.Parent.Size = UDim2.new(0, 0, 1, 0)
game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Anchored = false
end
function Start()
script.Parent.Size = UDim2.new(0, 0, 1, 0)
LastStart = tick()
tween:Play()
script.Parent.Parent.Visible = true
game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Anchored = true
end
inputServ.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E and (game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Position - part.Position).Magnitude < dist then
Start()
end
end)
inputServ.InputEnded:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E then
Cancel()
end
end)
Works for me, might need to change the timing a bit
Where do I put the elseif?
local inputServ = game:GetService("UserInputService")
local tweenServ = game:GetService("TweenService")
local dist = 5
local text = script.Parent.Parent.Parent.e
local part = workspace.Thing
local lights = false
local canDo = false
local tweenInf = TweenInfo.new(1)
local tween = tweenServ:Create(script.Parent, tweenInf, {Size = UDim2.new(1, 0, 1, 0)})
local LastStart = tick()
spawn(function()
while wait() do
if tick() - LastStart > 1 then
Cancel()
end
if (game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Position - part.Position).Magnitude < dist then
text.Visible = true
if lights then
text.Text = "<E> to turn off lights"
elseif lights == false then
text.Text = "<E> to turn on lights."
end
else
text.Visible = false
end
end
end)
function Cancel()
LastStart = tick()
script.Parent.Parent.Visible = false
tween:Cancel()
script.Parent.Size = UDim2.new(0, 0, 1, 0)
game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Anchored = false
end
tween.Completed:Connect(function()
if tick() - LastStart > 0.6 and tick() - LastStart < 1 then
print("Toggled Lights")
lights = not lights
workspace.Thing.PointLight.Enabled = not workspace.Thing.PointLight.Enabled
end
LastStart = tick()
end)
function Start()
script.Parent.Size = UDim2.new(0, 0, 1, 0)
LastStart = tick()
tween:Play()
script.Parent.Parent.Visible = true
game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Anchored = true
end
inputServ.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E and (game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Position - part.Position).Magnitude < dist then
Start()
end
end)
inputServ.InputEnded:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E then
Cancel()
end
end)
Thanks, this worked but there is a tiny delay before letting the player go and hiding the UI.
Play around with the timing?..
Is there also a way to make it like a hold e thing in jailbreak where it’s a circle?
Radial sprite sheet or a bunch of frames that make up a circle and gradually become visible
I need help with using the web app thing lol, can you send over a place with it set up?
I’ve never used it and I’m logging off, you’re on your own
Oh ok, goodbye lol.