I want to change the speed of certain animations I made for the player depending on the tool that they have equipped, and I want to do it in a server script. I don’t want to do it in a local script because I fear that it is easily exploitable.
It works like this:
- A server script is used to make a remote event that uses a parameter that specifies the animation that is played and changes the speed depending on what weapon is equipped (another parameter)
- A local script fires this remote event with the parameters that are needed.
The problem is that, when this is executed, the server script throws an error that says the animationtrack parameter is nil, even though it isn’t nil on the client.
I’ve eventually noticed that all player animations when replicated to the server aren’t assigned their previous names and that they are all just named “Animation”.
With this in mind, is there any way I could change the speed of the animations in the server, or in a manner that isn’t exploitable?
Below isn’t all of my code, but only the parts that I think are part of the problem or could be used to solve it.
--Server Script
Attack.OnServerEvent:Connect(function(player, weapon:string, animTrack:AnimationTrack)
animTrack:AdjustSpeed(WeaponData[weapon].Speed)
end)
--Local Script
local ChosenAnim
for _, anim in pairs(AttackAnims) do
if anim:GetAttribute("AnimationNumber") == AnimCount then
ChosenAnim = Animator:LoadAnimation(anim)
end
end
ChosenAnim:Play()
ChosenAnim:GetMarkerReachedSignal("AttackStart"):Connect(function()
AttackEvent:FireServer(Weapon.Name, ChosenAnim)
print(ChosenAnim)
end)
--Module Script (Not too important. Just holds some values I need.)
Weapons["Fists"] = {
["Speed"] = 1,
},
}
Weapons["Boxing Gloves"] = {
["Speed"] = 1.25,
},
}
The exact error I’m getting is: ServerScriptService.WeaponScripts.AttackServer:31: attempt to index nil with ‘AdjustSpeed’
