Still have questions? Join our Discord server and get real time help.
1

# Why doesn't my remote event change a NumberValue server wide?

I've used a remote event which changes a NumberValue which represents the speed of a vehicle in the workspace. It is fired by a local script which passes the speed of the vehicle as the 2nd parameter, this occurs every frame. I want it to change the NumberValue server wide so it can be read by other scripts in the workspace but, this doesn't happen.

--local script

local changeSpeedEvent = seat.Parent.Parent:WaitForChild("SpeedChange")
local RunService = game:GetService("RunService")

RunService.Heartbeat:Connect(function()
changSpeedEvent:FireServer(setSpeed)

--Listener script

local SpeedChangeEvent = script.Parent.SpeedChange
local speed = script.Parent.Speed.Value

SpeedChangeEvent.OnServerEvent:Connect(function(player,newSpeed)
speed = newSpeed
end)


0
0
"changSpeedEvent" line 7 spelt wrong CrazyFlankz 25 — 14d

0
sleazel 394
14 days ago
Edited 14 days ago

In server script line 4, you are changing value of local speed variable, instead of referencing NumberValue:

local speed = script.Parent.Speed.Value


What you should do instead is:

--Listener script

local SpeedChangeEvent = script.Parent.SpeedChange
local speed = script.Parent.Speed --copy reference, instead of value

SpeedChangeEvent.OnServerEvent:Connect(function(player,newSpeed)
speed.Value = newSpeed --set value here
end)