i have a local script that fires the server and the server will get an animation dependent on a numbervalue in the players character, but you can spam click it and the task.waits wont stop it and i dont know what to do
--this is the client firing to server
local plr : Player = game.Players.LocalPlayer
local char : Character = plr.Character or plr.CharacterAdded:Wait()
local hum : Humanoid = char:WaitForChild("Humanoid")
local hrp : BasePart = char:WaitForChild("HumanoidRootPart")
local uis :UserInputService = game:GetService("UserInputService")
local SCHBE : RemoteEvent = game.ReplicatedStorage.Events:WaitForChild("ServerConnectionM1Event")
local punchFolder = game.ReplicatedStorage:WaitForChild("Animations"):WaitForChild("PLACEHOLDERM1S")
local function HandleInput(input : InputObject,gpe)
if gpe then
return
end
if input then
if input.UserInputType == Enum.UserInputType.MouseButton1 then
SCHBE:FireServer(char,hum,hrp, punchFolder)
end
end
end
uis.InputBegan:Connect(HandleInput)
--this is server
local m1Event : RemoteEvent = game.ReplicatedStorage.Events:WaitForChild("ServerConnectionM1Event")
local lasttime = 0
local function GetM1Num(plr : Player,char : Character ,hum : Humanoid,hrp : BasePart, AnimFolder : Folder)
local currentp = tick()
if currentp - lasttime >3 then
char.M1Val.Value = 0
end
local M1Service = require(script.M1Service)
local M1Val = char["M1Val"]
if M1Val.Value == 1 then
M1Val.Value += 1
M1Service.HandleM1s(plr,char,hum,hrp,AnimFolder,1)
task.wait(.7)
elseif M1Val.Value == 2 then
M1Val.Value += 1
M1Service.HandleM1s(plr,char,hum,hrp,AnimFolder,2)
task.wait(.7)
elseif M1Val.Value == 3 then
M1Val.Value += 1
M1Service.HandleM1s(plr,char,hum,hrp,AnimFolder,3)
task.wait(5)
elseif M1Val.Value == 0 then
print("Tried")
M1Val.Value += 1
M1Service.HandleM1s(plr,char,hum,hrp,AnimFolder,0)
task.wait(.7)
end
lasttime = tick()
end
m1Event.OnServerEvent:Connect(GetM1Num)