Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Mounted turret script is unresponsive?

Asked by 6 years ago

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:

01seat = script.Parent.Seat
02turretbase = script.Parent.TurretBase
03 
04 
05seat:GetPropertyChangedSignal("Occupant"):Connect(function()
06    while seat.Occupant ~= nil do
07        local direction =   script.Parent.GetMouse:InvokeClient(game.Players:FindFirstChild(seat.Occupant.Parent.Name),seat.Occupant)
08        turretbase.CFrame = CFrame.new(turretbase.Position,direction)
09        wait(0.1)
10    end
11end)

client sided script (local script)

1mouse = game.Players.LocalPlayer:GetMouse()
2 
3function script.Parent.GetMouse.OnClientInvoke(player,occupant)
4    return mouse.hit.p
5end
0
Please help if you can, I can't seem to fix it! I've tried parenting the local script to ReplicatedFirst, but that doesn't work! SnazzySpider67 53 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

You need to set OnClientInvoke to a function - either one you pass in or an anonymous one like below. Change your local script to:

1mouse = game.Players.LocalPlayer:GetMouse()
2 
3-- 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
4function script.Parent.GetMouse.OnClientInvoke = function(occupant)
5    return mouse.hit.p
6end
Ad

Answer this question