script.Parent.Event.OnClientEvent:Connect(function(plr)
local player = plr
local mouse = player:GetMouse()
mouse.KeyDown:connect(function(key)
if key:lower() == "e" or key:upper() == "E" then
script.Parent.EngineEvent:FireServer()
end
end)
mouse.KeyDown:connect(function(key)
if key:lower() == "w" or key:upper() == "W" then
script.Parent.SpeedUp:FireServer()
end
end)
end)
A local script will not work here, you need to put a normal ‘Script’ instance, and set its RunContext to ‘Client’
Alright, so heres some things wrapped up, LocalScripts only work when parented to PlayerGui, StarterPlayerScripts, StarterCharacterScripts, etc… I see what you are trying to do, heres a way, you can insert a ObjectValue
and parent it to the player, name it “VehicleObject”.
Use the server script to set the value of VehicleObject to the VehicleSeat Instance.
and then you can insert a localscript into starterplayerscripts, and past this (its your own script, but fixed):
local player = game.Players.LocalPlayer
local canStart = false
local UIS = game:GetService("UserInputService")
local vehicleSeat = player:FindFirstChild("VehicleObject")
UIS.InputEnded:Connect(function(input,gp)
if gp then return end
if input.KeyCode == Enum.KeyCode.E then
if vehicleSeat.Value ~= nil and canStart then
vehicleSeat.EngineEvent:FireServer()
end
elseif input.KeyCode == Enum.KeyCode.W then
if vehicleSeat.Value ~= nil and canStart then
vehicleSeat.SpeedUp:FireServer()
end
end
end)
script.Parent.Event.OnClientEvent:Connect(function(plr)
canStart = true
end)
again, this still has multiple issues, so I recommend you to finish learning about how local, server scripts work and all that, then proceed.
Isnt it
“Doesn’t work”?
(Just so none make fun of you in the future for bad grammar)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.