local script
local ReplicatedStorage = game:GetService("ReplicatedStorage") local Mouse = game.Players.LocalPlayer:GetMouse() local player = game.Players.LocalPlayer script.Parent.Equipped:Connect(function() Mouse.Icon = "rbxasset://textures/GunCursor.png" end) script.Parent.Unequipped:Connect(function() Mouse.Icon = "rbxasset://SystemCursors/Arrow" end) script.Parent.Activated:Connect(function() if Mouse.Target.Name == ("Target") then game.Workspace.GunShot:Play() Mouse.Target:Destroy() local GunLevel = script.Parent.GunLevel ReplicatedStorage.GunHit:FireServer(player, GunLevel) end end)
global script
local ReplicatedStorage = game:GetService("ReplicatedStorage") game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" local Points = Instance.new("IntValue") Points.Name = "GunHits" local GunLevel = Instance.new("IntValue") GunLevel.Name = "GunLevel" GunLevel.Value = 1 leaderstats.Parent = player Points.Parent = leaderstats GunLevel.Parent = leaderstats end) ReplicatedStorage.GunHit.OnServerEvent:Connect(function(player, GunLevel) player.leaderstats.GunHits.Value = player.leaderstats.GunHits.Value + GunLevel.Value end)
When using :FireServer() the player argument is already passed so you dont need to pass it again. Just do
ReplicatedStorage.GunHit:FireServer(GunLevel)