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

My Gun Script Is not letting me pass multiple arguments?

Asked by 3 years ago

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)

1 answer

Log in to vote
0
Answered by 3 years ago

When using :FireServer() the player argument is already passed so you dont need to pass it again. Just do


ReplicatedStorage.GunHit:FireServer(GunLevel)
Ad

Answer this question