Hi there, scripters!
I have a problem with my turret script, which is intended to point towards the seat occupant's mouse coordinates, but it isn't sending a remote function that requests the mouse coordinates from a local script. I've had tons of problems with remote functions/events that send signals to the client before. Any help is appreciated!
server sided script:
seat = script.Parent.Seat turretbase = script.Parent.TurretBase seat:GetPropertyChangedSignal("Occupant"):Connect(function() while seat.Occupant ~= nil do local direction = script.Parent.GetMouse:InvokeClient(game.Players:FindFirstChild(seat.Occupant.Parent.Name),seat.Occupant) turretbase.CFrame = CFrame.new(turretbase.Position,direction) wait(0.1) end end)
client sided script (local script)
mouse = game.Players.LocalPlayer:GetMouse() function script.Parent.GetMouse.OnClientInvoke(player,occupant) return mouse.hit.p end
You need to set OnClientInvoke to a function - either one you pass in or an anonymous one like below. Change your local script to:
mouse = game.Players.LocalPlayer:GetMouse() -- You're not using the occupant argument here, but I left it in to show that the player argument isn't passed from server to client - i.e. InvokeClient(player, arg1) only uses the player argument to know who to send it to - it doesn't pass it to the client, so the client only sees arg1 function script.Parent.GetMouse.OnClientInvoke = function(occupant) return mouse.hit.p end