I'm trying to make a throwable bomb but when I send a variable trough a RemoteEvent it returns as nil
-- Local script: local player = game.Players.LocalPlayer local mouse = player:GetMouse() mouse.Button1Down:Connect(function() game.ReplicatedStorage.Events.BombEvent:FireServer(mouse) end)
-- Server script: game.ReplicatedStorage.Events.BombEvent.OnServerEvent:Connect(function(plr, mouse) print(mouse.Target) -- The mouse variable returns as nil end)
You cannot pass the mouse object from the client to the server, it will result in nil because the server cannot see the mouse object in the first place.
You could just send the mouse.Target from the client to the server instead so it would look kinda like this
local player = game.Players.LocalPlayer local mouse = player:GetMouse() mouse.Button1Down:Connect(function() game.ReplicatedStorage.Events.BombEvent:FireServer(mouse.Target) end)
And the server would look like
game.ReplicatedStorage.Events.BombEvent.OnServerEvent:Connect(function(plr, mouse) if mouse then print(mouse.Name) --//This means that the mouse.Target we sent on the client did in fact exist end end)