Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I stop my spell script from working after a few seconds?

Asked by 3 years ago

So I'm making a game that involves spells, but I can't figure out how to make it so that after 3 seconds, the click detector won't work unless you say the spell again. How can I do this? Is it possible? I tried a wait(), but it just pauses the whole script.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local test = true
local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEventTest")

local player = game.Players.LocalPlayer
    local mouse = player:GetMouse()

player.Chatted:connect(function(msg)
    if msg:lower() == "feusur" and  player.TeamColor == BrickColor.new("Mulberry") then
        local number = 1
        mouse.Button1Down:Connect(function()
            if number == 1 then
            if test == true then
            local period = mouse.Hit
            local boo = Vector3.new(0, 0, 90)
            remoteEvent:FireServer(period, boo)
            test = false
            number = 0
            wait(7)
            test = true
                end
            end
          end)
    end
end)

1 answer

Log in to vote
0
Answered by 3 years ago

Have you tried changing the line 20's test to false?

0
That just disables it after one use. youngsavagehard 20 — 3y
0
OOF snipperdiaper 120 — 3y
Ad

Answer this question