In the script server side I have:
local hoverEnterAmmo = game.ReplicatedStorage.HoverEnterAmmo num = script.Parent.AmmoNumStored math.randomseed(tick()) num.Value = math.random(1,50) script.Parent.ClickDetector.MouseHoverEnter:connect(function(Player) print(num.Value) hoverEnterAmmo:FireClient(Player, num.Value) end)
In the local script I have:
local hoverLeaveAmmo = game.ReplicatedStorage:WaitForChild("HoverLeaveAmmo") hoverEnterAmmo.OnClientEvent:connect(function(player, num) textForHover.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y + 15) textForHover.Visible = true print(num.." "..num) totalAmmo = totalAmmo lowerValueOnScreen() end)
Not sure I'm doing it correctly at all, when I print(num) in the local script I get nil what am I doing wrong? Thanks for your help it's much appreciated!
Even though the paramater for the player is required for FireClient, this does not transfer across to the OnClientEvent in the local script. So in your local script, the player argument would be num and the num argument would be nil. So to fix this, all you should need to do is remove the player argument in the local script:
hoverEnterAmmo.OnClientEvent:Connect(function(num)