I want to get a bool value named after a player’s UserId but it does not work saying that the instance simply does not exist. I tried getting the id to be a tostring(plr.UserId) variable but that still does not work.
If you have another way for server side, per player debounces, feel free to let me know to use it instead.
Any help is greatly appreciated!
Server Script Code
local repStorage = game:GetService("ReplicatedStorage")
local idfolder = workspace:WaitForChild("idFolder")
local debouncefolder = gameplay:WaitForChild("GrassDebounce")
local remotes = repStorage:WaitForChild("remotes")
local cd = 2
remotes.remoteEventOk.OnServerEvent:Connect(function(plr)
local id = tostring(plr.UserId)
local db = grssDb.id.Value
local char = plr.Character
local hum = char.Humanoid
local floormat = hum.FloorMaterial
if floormat == Enum.Material.Grass and not db then
db = true
hum.WalkSpeed = 0
hum.JumpPower = 0
wait(cd)
db = false
hum.WalkSpeed = 19
hum.JumpPower = 51
end
end)
Local Script Code
local CAS = game:GetService("ContextActionService")
local repStorage = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local idfolder = workspace:WaitForChild("idFolder")
local remotes = repStorage:WaitForChild("remotes")
local debouncefolder = idfolder:WaitForChild("GrassDebounce")
local plr = players.LocalPlayer
local cd = 2
local function groundTouch(actionName, state)
local id = tostring(plr.UserId)
local db = debouncefolder.id.Value
if state == Enum.UserInputState.Begin and not db then
remotes.remoteEventOk:FireServer()
if plr.Character.Humanoid.FloorMaterial == Enum.Material.Grass then
plr.Character.Humanoid.WalkSpeed = 0
plr.Character.Humanoid.JumpPower = 0
--print("touched grass")
wait(cd)
plr.Character.Humanoid.WalkSpeed = 19
plr.Character.Humanoid.JumpPower = 51
end
end
end
CAS:BindAction("TouchGround", groundTouch, false, Enum.KeyCode.E)
This is the server side script error.
This is the client side script error.
Please note that some names are not the same to protect my game as much as I can.
You could it’s still a table which you can put information in, but there is no need to require it every time the function is called as module scripts only run once so you could store what it returns in a local variable.
I’d just make a Per Player debounce on the server side with a table and a normal debounce on the LocalScript because the LocalScript doesn’t replicate to other clients.
The LocalScript should look something like this:
-- Your variables or whatever
local Debounce = false
local function groundTouch(actionName, state)
if Debounce or state ~= Enum.UserInputState.Begin then return end
Debounce = true
remotes.remoteEventOk:FireServer()
if plr.Character.Humanoid.FloorMaterial ~= Enum.Material.Grass then
wait(2)
Debounce = false
return
end
plr.Character.Humanoid.WalkSpeed = 0
plr.Character.Humanoid.JumpPower = 0
wait(2)
plr.Character.Humanoid.WalkSpeed = 19
plr.Character.Humanoid.JumpPower = 51
Debounce = false
end
-- The ContextActionService Bind
Thank you, @Profituber@dthecoolest !
I just remade the whole debounce thing on the server side* and completely scrapped the client side system only firing the event!