Hey!
So in my game, i wanted to make it so that if a player is crouching on a bounce pad, the bounce pad wont activate/bounce the player. So i added a bool value inside the player character that shows whether the player is crouching or not, and the bounce pad script checks whether this value is true or false (so if its true then the player is crouching).
But the issue is that the crouching bool only turns on on the client side (because the crouching system uses a local script), and on the server this value stays false (because the bounce pad script is server sided).
How can i change the crouching value on the server-side?
remote events.
they allow for client-server and server-client communication.
client implementation:
local isCrouching = false
function crouch()
isCrouching = not isCrouching
game.ReplicatedStorage.crouchEvent:FireServer(isCrouching)
end
server implementation:
--// Put this part into a script in ServerScriptService
game.ReplicatedStorage.crouchEvent.OnServerEvent:Connect(function(player, isCrouching)
player:SetAttribute("isCrouching", isCrouching)
end
--// Bounce pad logic, put this elsewhere.
if not player:GetAttribute("isCrouching") then
--// Add velocity
end
I will add that you will have to manually create the remote events, they won’t just magically appear if you try calling them.