Hello, I have a script that is supposed to attach the car to an rc car. But It doesn't want to work. It still is attached to the character and nothing happens. There is no error in output. It is a localscript. I used remoteevents.
local clickDetector = script.Parent.ClickDetector function onMouseClick() game.ReplicatedStorage.CamP406:FireServer() end clickDetector.MouseClick:connect(onMouseClick)
Receive (in startergui and is a server script)
local cam = game.Workspace.CurrentCamera repeat wait() until game:service("ContentProvider").RequestQueueSize == 0 -- This waits until the game is loaded up game.ReplicatedStorage.CamP406.OnServerEvent:connect(function(plr) cam.CameraSubject = game.Workspace.P406.Shell cam.CameraType = Enum.CameraType.Attach end)
Server script :
local clickDetector = script.Parent.ClickDetector function onMouseClick(play) game.ReplicatedStorage.CamP406:FireClient(play,play) end clickDetector.MouseClick:connect(onMouseClick)
Local script :
remote = game.ReplicatedStorage.CamP406 plr = game:GetService("Players").LocalPlayer cam = workspace.CurrentCamera remote.OnClientEvent:Connect(function(player) if player.UserId == plr.UserId then cam.CameraSubject = workspace.P406.Shell cam.CameraType = Enum.CameraType.Attach end end)
You should put LocalScript in StarterGui and put Server script in part with ClickDetector.