I've basically created a slide script for players to slide under objects in my game. You press X to slide, and all the scripting parts work perfectly so far. The only problem is that there's no actual velocity being applied to the HumanoidRootPart in the server mode, sliding is only working in studio.
This is the server-side code for my sliding script that gets fired via RemoteFunction:
local char = script.Parent local hum = script.Parent:WaitForChild("Humanoid") local root = script.Parent:WaitForChild("HumanoidRootPart") local cooldowns = { ["Slide"] = false, } local anims = { ["Slide"] = 01419568155, } for i,v in pairs(anims) do local anim = Instance.new("Animation") anim.AnimationId = "rbxassetid://"..v anim = hum:LoadAnimation(anim) anims[i] = anim end function Slide() if not cooldowns.Slide then cooldowns.Slide = true anims.Slide:Play() root.Velocity = root.CFrame.lookVector*95 wait(1.25) cooldowns.Slide = false end end local event = Instance.new("RemoteFunction") event.Name = "SlideEvent" event.Parent = char function event.OnServerInvoke() Slide() end
This is the client-side code that gets the input for sliding:
local plr = game.Players.LocalPlayer local char = plr.Character local ctx = game:GetService("ContextActionService") local firing = false local event = char:WaitForChild("SlideEvent") ctx:BindAction("Slide",(function(a,c,t) if c == Enum.UserInputState.Begin then if not firing then firing = true event:InvokeServer() firing = false end end end),false,Enum.KeyCode.X)
There are no issues with the actual sliding animation, it plays no matter what. The only problem is that the velocity propels my character in studio but doesn't do the same in server mode.
This is me in studio sliding: https://gyazo.com/2923940e903ebbc3cb91250d7ccf7c19
This is me in play mode: https://gyazo.com/35a63c374974fd036743e45d6798e57e
Any advice for how I should fix this? I feel like it's a velocity problem because I also have a double jump script where the animation plays but doesn't actually apply vertical force in play mode. The double jump script also works in studio.
I've also simplified the above scripts to say that "X" means slide, but in my game it's actually Shift+C. If you want to go and look at the place, feel free. https://www.roblox.com/games/1411630639/Dorado
I haven't run into this kind of problem on any other place that I've made double jumping or sliding.
Edit: I've fixed the problem in my game by using BodyVelocity but I'm leaving the question open because I still want to know why Part.Velocity doesn't work server-side for my character. Does it not replicate or something?