I'm making a filtering enabled car placement system that works in Studio perfectly but in online mode the remote events do not execute. They are located in ReplicatedStorage.
Relevant server code:
spawnpreviewevent.OnServerEvent:connect(function(player,args) --event that spawns the preview of the car
print("spawn event started")
--event to spawn the preview
local previewclone = args[1]:Clone()
previewclone.Name = player.Name.."-preview"
previewclone.Parent = workspace
previewclone.Position = Vector3.new(args[2],args[3],args[4])
print("spawned brick")
end)
movepreviewevent.OnServerEvent:connect(function(player,args) --event that moves the car according to your mouse.hit
print("move event started")
--event to move the preview
local previewbrick = workspace:FindFirstChild(player.Name.."-preview")
if args[5] == "no" then
previewbrick.BrickColor = BrickColor.new("Bright red")
else
previewbrick.BrickColor = BrickColor.new("Bright green")
end
previewbrick.Position = Vector3.new(args[2],args[3],args[4])
print("move")
end)
placecarevent.OnServerEvent:connect(function(player,args) --the event that places the car and clears any other cars owned by that player; also deletes the preview brick (which is just a green rectangle that indicates where the car is being placed)
--event to place the car
print("placing car")
local findcar = workspace:FindFirstChild(player.Name.." Car")
if findcar then
findcar:Destroy()
end
local previewbrick = workspace:FindFirstChild(player.Name.."-preview")
if previewbrick.BrickColor == BrickColor.new("Bright red") then
else
local cartoclone = cars:FindFirstChild(args[1]):Clone()
cartoclone.Name = player.Name.." Car"
cartoclone.Parent = workspace
cartoclone:MakeJoints()
wait()
cartoclone:MoveTo(previewbrick.Position+Vector3.new(0,5,0))
previewbrick:Destroy()
end
end)
Relevant client code:
spawnbutton.MouseButton1Click:connect(function() --Essentially tells the server to spawn the preview brick and passes along some information
placing = true
x.Value = mouse.Hit.X
y.Value = mouse.Hit.Y
z.Value = mouse.Hit.Z
spawnpreviewevent:FireServer({preview, x.Value,y.Value,z.Value})
main.Visible = false
spawn.Visible = false
end)
mouse.Move:connect(function() --When the mouse moves, tell the server to move the preview brick
if placing == true then
x.Value = mouse.Hit.X
y.Value = mouse.Hit.Y
z.Value = mouse.Hit.Z
local checkforpreview = workspace:FindFirstChild(player.Name.."-preview")
if checkforpreview and mouse.Target then
mouse.TargetFilter = checkforpreview
if mouse.Target.Name ~= "Road" then
canplace = false
movepreviewevent:FireServer({checkforpreview, x.Value,y.Value,z.Value,"no"})
else
canplace = true
movepreviewevent:FireServer({checkforpreview, x.Value,y.Value,z.Value})
end
end
end
end)
mouse.Button1Down:connect(function() --When you click (if your mouse is pointing at a road), tell the server to place the car.
if canplace == true then
placing = false
placecarevent:FireServer({name.Value})
main.Visible = true
else
end
end)
As I said, all of this works perfectly in Studio; however, when in online mode, the remote events don't even execute. What have I done wrong here?
