Hello, I've been working on this script for a few hours now but it isn't working. Basically, there's a BoolValue and when it's set to true, it's meant to make a part move when you press the keys WASD. Here's the code (The 1st is a LocalScript, the 2nd one is a Script).
local player = game.Players.LocalPlayer
local spaceship = game.Workspace:WaitForChild(player.Name.."Spaceship")
local WKeyHeld = false
local AKeyHeld = false
local SKeyHeld = false
local DKeyHeld = false
local EKeyHeld = false
local QKeyHeld = false
local g = workspace:WaitForChild("Main"):WaitForChild("gameStart")
-- NOTE: SpaceshipCamera is PrimaryPart
function onKeyPress(inputObject,gameProcessed)
if g.Value == true then
if inputObject.KeyCode == Enum.KeyCode.W then
WKeyHeld = true
while WKeyHeld do
wait(0.0001)
game.ReplicatedStorage:WaitForChild("Move"):FireServer(spaceship:WaitForChild(player.Name), spaceship:WaitForChild("SpaceshipCamera"), Vector3.new(0,0,-0.5))
end
end
if inputObject.KeyCode == Enum.KeyCode.A then
AKeyHeld = true
while AKeyHeld do
wait(0.0001)
game.ReplicatedStorage:WaitForChild("Move"):FireServer(spaceship:WaitForChild(player.Name), spaceship:WaitForChild("SpaceshipCamera"), Vector3.new(-0.5,0,0))
end
end
if inputObject.KeyCode == Enum.KeyCode.S then
SKeyHeld = true
while SKeyHeld do
wait(0.00001)
game.ReplicatedStorage:WaitForChild("Move"):FireServer(spaceship:WaitForChild(player.Name), spaceship:WaitForChild("SpaceshipCamera"), Vector3.new(0,0,0.5))
end
end
if inputObject.KeyCode == Enum.KeyCode.D then
DKeyHeld = true
while DKeyHeld do
wait(0.00001)
game.ReplicatedStorage:WaitForChild("Move"):FireServer(spaceship:WaitForChild(player.Name), spaceship:WaitForChild("SpaceshipCamera"), Vector3.new(0.5,0,0))
end
end
end
end
function onKeyRelease(inputObject,gameProcessed)
if g.Value == true then
if inputObject.KeyCode == Enum.KeyCode.W then
WKeyHeld = false
end
if inputObject.KeyCode == Enum.KeyCode.A then
AKeyHeld = false
end
if inputObject.KeyCode == Enum.KeyCode.S then
SKeyHeld = false
end
if inputObject.KeyCode == Enum.KeyCode.D then
DKeyHeld = false
end
end
end
game:GetService("UserInputService").InputBegan:Connect(onKeyPress)
game:GetService("UserInputService").InputEnded:Connect(onKeyRelease)
local spaceship = game.Workspace:WaitForChild("Spaceship")
local spaceshipMesh = spaceship:WaitForChild("SpaceshipMesh")
game.Players.PlayerAdded:Connect(function(v)
local playerSpaceship = spaceship:Clone()
playerSpaceship.Name = v.Name.."Spaceship" playerSpaceship.SpaceshipMesh.Position = Vector3.new(-1.25, 24.75, 239)
playerSpaceship.SpaceshipCamera.Position = Vector3.new(-1.8, 20, 265)
playerSpaceship.Parent = game.Workspace
playerSpaceship:WaitForChild("SpaceshipMesh").Anchored = false
playerSpaceship:WaitForChild("SpaceshipMesh").Name = v.Name
v:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("TextLabel").Visible = false
end)
game.ReplicatedStorage.Move.OnServerEvent:Connect(function(player, mesh, camera, direction)
mesh.Position = mesh.Position + direction
camera.Position = camera.Position + direction
end)
Any help would be appreciated! :D

7 comments
Local? or workspace? Nvm local scripts can move blocks but no one else can see them. Ill try to edit the script
LocalScript
The script is moving camera angles legit no block instances have been mentioned. Probably moving them on the main script
It fires an ReplicatedEvent and then the server moves it from there.
Your :FireServer(...) has to send (mesh, camera, direction). Right now you're sending (player, camera, direction).
I don't know why but the mesh moves too, the server seems to move the mesh aswell.
Oh, I found out why! The game mesh is the name of the player, to make the racing system in my game more easy.