Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

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

Asked by 14 days ago

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
Your already a master.. Serpawh -4 — 14d
0
"changSpeedEvent" line 7 spelt wrong CrazyFlankz 25 — 14d

1 answer

Log in to vote
0
Answered by
sleazel 394 Moderation Voter
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)

Ad

Answer this question