Ok, so I am trying to do an ability where you can stop time only when you are holding a sword. So, here is the problem. It works fine the first time before I pull out my sword, when you press the button, it will only do it when you are holding the sword. But after, even when you aren't holding the sword, it still stops time! Does anyone have any ideas what i need to do? Thank you.
Also, i have tried wrapping it in a loop, but that just crashes it. (also, this isn't required but I'm wondering how i could put an animation to play when you do it. Thanks!
Here is the script: (It's a local script inside the tool)
local UIS = game:GetService("UserInputService")
local tool = script.Parent
local player = game.Players.LocalPlayer
local enabled = false
local remote = game:GetService("ReplicatedStorage"):FindFirstChild("TimeStop")
tool.Equipped:Connect(function()
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
if enabled == false then
enabled = true
remote:FireServer("TimeStop")
for i=70, 100,5 do
wait()
workspace.Camera.FieldOfView = i
end
for i=100, 70,-5 do
wait()
workspace.Camera.FieldOfView = i
end
wait(55)
enabled = false
end
end
end)
end)

4 comments
use "task.wait()" if pro, performance difference is very noticeable, create 1000 small parts and move each of them by a bit every "wait()", then try the same with "task.wait()"
Thank you, I will see if this works! The reason I used the wait() was because I was trying to make a cooldown.
Yep, it works! Thank you so much!
If you wanna make a cooldown, you can add the wait(55) after you put enabled = false. After that, you can add enabled = true after wait(55). The cooldown will be 55 seconds.