Hello, I want to achieve a node based train kit. I only have one thing missing however. Controlling the speed. This requires some way to change a value server-sided instead of client sided while keeping in mind that it should only work with the driver on the seat.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = script.Parent.values.accel
local key = game:GetService("UserInputService")
local dec = script.Parent.values.decel
key.InputBegan:Connect(function(Input, IsTyping)
if IsTyping then return end
if Input.KeyCode == Enum.KeyCode.Six then
remoteEvent:FireServer(game.Workspace.Line.Trains.Train2.CurrentSpeed.Value)
end
end)
key.InputBegan:Connect(function(Input, IsTyping)
if IsTyping then return end
if Input.KeyCode == Enum.KeyCode.Seven then
dec:FireServer(game.Workspace.Line.Trains.Train2.CurrentSpeed.Value)
end
end)
and scripts look like this :
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = script.Parent.values.accel
local dec = script.Parent.values.decel
local function onCreatePart(player, partColor, partPosition)
print(player.Name .. " fired the RemoteEvent")
script.Parent.Parent.Train2.CurrentSpeed -= 2
script.Parent.Parent.Train.CurrentSpeed -= 2
script.Parent.Parent.Train3.CurrentSpeed -= 2
end
wait(5)
remoteEvent.OnServerEvent:Connect(onCreatePart)
(Currentspeed controls the speed)
I have tried multiple things including direct script ect. never worked.
any ideas or modified script would help.
Any help is appreciated.