I just want the walkspeed of the character to be constantly set to 1.
If the client changes the humanoids walkspeed, for some reason the server is not able to change it to 1 anymore, same goes with jumppower. This happens in both studio and in-game when I join the game from website.
I have tried looking if my code has any errors, it doesnt, I have confirmed that it indeed does run the code that sets the walkspeed to 1, and the serverside does also THINK that my humanoid walkspeed is 1, but clearly thats not true on client.
StunPlayer = function(Enemy,Duration)
if Enemy.IFrames.Value == true then return end
if Enemy.Blocking.Value == true then return end
local StunValue = Instance.new("BrickColorValue",Enemy)
StunValue.Name = "GotStunned"
deb:AddItem(StunValue,Duration)
task.spawn(function()
repeat
Enemy.Humanoid.JumpPower = 0
Enemy.Humanoid.WalkSpeed = 1
Enemy.Activu.Value = true
task.wait(0.06)
until not Enemy:FindFirstChildWhichIsA("BrickColorValue")
Enemy.Humanoid.JumpPower = 50
Enemy.Humanoid.WalkSpeed = 25
Enemy.Activu.Value = false
end)
return StunValue
end,
You should be able to send a bug report and get it put through the pre-approval process. Its most likely to do with either your animation controller or something else in your script.
I do not have the bug report button, it is just not there, even after switching browsers and everything. Anyway, I’m sorry but I do not quite understand how the animation controller could be the culprit, could you please explain?
Your running animations to swing the sword I am guessing? depending on the priority set in the animator it could be affecting the jumppower and walkspeed.
I mean you are changing the speed on client anyway, I would personally recommend changing it on the serverside if possible, and if it works then that would be a better alternative.
If you haven’t watched the video, I recommend doing so as it visualizes the situation very clearly. I am changing my humanoids walkspeed to 1 on the server, and then once I change it on client, the server can not change it to 1 anymore.
Because it does not recognise client made changes, the server will still think the walkspeed is 1. If possible try make the changes on the server compared to client, as it will have more control over it.
Although can I ask you to try an alternative?
Try this instead:
Humanoid.WalkSpeed -= 0.1 --subtracts from the walk speed
Humanoid.WalkSpeed = 5 -- sets the walk speed, replicated
Perhaps its the repeat that you have? perhaps the server is running the walkspeed change too early and is reversed by the repeated task still being ran?
Yes, I am, I have even tried going into ANOTHER game I worked on in the past to see if the issue also persists there, and yes, it does. This hasnt been happening before, so this must be some sideproduct of a patch ROBLOX is currently trying to push out is what I’m guessing.
After further investigation it’s become apparent to me that this is likely not fixeable by regular developers and is probably a ROBLOX engine issue. I have tried to reproduce the same issue in other games and It has indeed happened there too, this is most likely a byproduct of some patch ROBLOX is pushing out. Will be closing the thread and messaging Bug-Support now that I’ve been told how to.
Actually a quick fix is to just subtract a small amount of the walk speed / jump power and then add it back.
something like
Humanoid.WalkSpeed -= 0.01
Humanoid.WalkSpeed += 0.01
-- this should be looped if its set continuously
The reason why it does not work is the fact that while it is changed on the client, IT DOES NOT replicate to the server, which means on the server you are trying to set it to a value which it already is so it does not change.
I highly doubt this is a Roblox bug, WalkSpeed has always had weird replication rules implemented (excluding that your scripts are actually the issue, which is likely). When changing WalkSpeed, I always do everything on the client in order to avoid any issues. My suggestion for you is to use Attributes and RunService to constantly set the character’s walkspeed to said attribute.
--Server Script
character:SetAttribute("WalkSpeedStepped" ,1)
task.wait(5) -- Stun for 5 seconds
character:SetAttribute("WalkSpeedStepped" , nil)
Remotes.ResetWalkspeed:FireClient(player, {
walkSpeed = 16, --What you want the walkspeed to be reverted to
}
--Local Script
game:GetService("RunService").RenderStepped:Connect(function()
local w = character:GetAttribute("WalkSpeedStepped")
if w then
character.Humanoid.WalkSpeed = w
end
end)
Remotes.ResetWalkspeed.OnClientEvent:Connect(function(data) -- We don't want the server to touch WalkSpeed, so the client will do it
data = data or {}
if data.jumpPower then
humanoid.JumpPower = data.jumpPower
end
if data.jumpHeight then
humanoid.JumpHeight = data.jumpHeight
end
if data.walkSpeed then
humanoid.WalkSpeed = data.walkSpeed
end
end)
What’s cool about this is that it’s very reliable and you can even check if the character is say, sprinting, and reset the walkspeed back to the sprint speed on the client event. (just wrote this so their may be bugs)
My bad, THIS version of the subtraction method did work! The one above didn’t for some reason…very weird. Either way, thank you. Still think this should be something that ROBLOX addresses…
This is an engine optimisation. Because the property doesn’t change in value, it’s not worth firing Instance.Changed and other signals. If the property doesn’t change, there is no new version to queue for replication either. It’s fairly important and isn’t likely to change.
local int = Instance.new("IntValue")
int.Changed:Connect(print)
int.Value = 1 --> fires
int.Value = 1
int.Value = 2 --> fires
@Fusionet’s idea to change these properties in a more centralised manner is pretty good. And in terms of fighting cheaters, WalkSpeed and JumpHeight really aren’t something a server would necessarily have to manage. It’s more effective to keep approximate track of how the player should be moving and have appropriate sanity checks in place.