I’m trying to covert my weapon animation code to a local script since running animations on the server isn’t the best.
I’ve tried using a remote event and sending a message that the local animation is now idle but It doesn’t feel very practical
how the old script worked was that
If the local animation has finished it would send a message “idle”
the server would check the message and if it matched the server state
it would change the server state to “idle” aswell
whats the best way to convert it to a local script?
tool.Equipped:Connect(function()
state = "equipping"
idle = char.Humanoid:LoadAnimation(animations.idle)
equip = char.Humanoid:LoadAnimation(animations.equip)
equip:Play()
equip:GetMarkerReachedSignal("ended"):Connect(function()
idle:Play()
state = "idle"
end)
end)
tool.Unequipped:Connect(function()
state = "unequipped"
stopanimations()
if canswing == true then
canswing = false
end
animationnumber = 1
if delaytask then
task.cancel(delaytask)
end
end)
function swing()
params.FilterDescendantsInstances = {char}
local randomswingaudio = math.random(1,#swings)
local hitchar = {}
local parts
if animationnumber == 1 then
current = char.Humanoid:LoadAnimation(animations.swing1)
elseif animationnumber == 2 then
current = char.Humanoid:LoadAnimation(animations.swing2)
elseif animationnumber == 3 then
current = char.Humanoid:LoadAnimation(animations.swing3)
end
current:Play()
current:GetMarkerReachedSignal("start"):Connect(function()
canswing = true
playsound(swings[randomswingaudio],1.5,1)
while canswing do
parts = workspace:GetPartBoundsInBox(char.HumanoidRootPart.CFrame * CFrame.new(0,-.5,-4),Vector3.new(5, 4, 6.5), params)
for i, v in pairs(parts) do
if v.Parent:FindFirstChildOfClass("Humanoid") and not table.find(hitchar, v.Parent) then
table.insert(hitchar, v.Parent)
local randomimpact = math.random(1,#impacts)
playsound(impacts[randomimpact],1.5,1)
v.Parent:FindFirstChildOfClass("Humanoid"):TakeDamage(35)
end
end
task.wait()
end
end)
current:GetMarkerReachedSignal("end"):Connect(function()
canswing = false
end)
current:GetMarkerReachedSignal("lol"):Connect(function()
if animationnumber == 3 then
animationnumber = 1
delaytask = task.delay(endlag,function()
state = "idle"
end)
else
if animationnumber < 3 then
state = "idle"
animationnumber += 1
end
end
end)
end
Thanks! shiva.