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

Why does my parameter come out as player?

Asked by 1 year ago

So when I added values on a local script, it worked correctly. But when I used parameters and remote events, it changed the value to player and I don't know why. Help please. Local Script:

local updateDogecoinEvent = game:GetService("ReplicatedStorage"):WaitForChild("UpdateDogecoin")
local setDogecoinEvent = game:GetService("ReplicatedStorage"):WaitForChild("SetDogecoin")

updateDogecoinEvent.OnClientEvent:Connect(function()
    local player = game.Players.LocalPlayer
    local dogecoin1 = player.PlayerScripts.changeDogeAmount.Doges.Value * 2
    local dogecoin2 = player.PlayerScripts.changeDogeAmount.NoobDoges.Value * 10
    local dogecoin = dogecoin1 + dogecoin2

    setDogecoinEvent:FireServer(dogecoin)
    print(dogecoin)
    player.PlayerScripts.changeDogeAmount.NoobDoges.Value = 0
    player.PlayerScripts.changeDogeAmount.Doges.Value = 0
end)

Server Script:

debounce = true
script.Parent.selll.Touched:Connect(function(leg)
    if debounce == true then
        debounce = false
        if game.Players:GetPlayerFromCharacter(leg.Parent) then
            print("doge sell")
            local player = game.Players:GetPlayerFromCharacter(leg.Parent)
            print(player)
            local updateDogecoinEvent = game:GetService("ReplicatedStorage"):WaitForChild("UpdateDogecoin")
            local setDogecoinEvent = game:GetService("ReplicatedStorage"):WaitForChild("SetDogecoin")
            local dogecoinGuiEvent = game:GetService("ReplicatedStorage"):WaitForChild("dogecoingui")
            updateDogecoinEvent:FireClient(player)
            setDogecoinEvent.OnServerEvent:Connect(function(dogecoin)
                print(dogecoin)
                player.leaderstats.Dogecoin.Value = dogecoin
                script.Sound.Playing = true
                dogecoinGuiEvent:FireClient(player)
            end)
        end
        wait()
        debounce = true
    end
end)
0
To clarify the first script is a local script. NeoDogez 18 — 1y
1
OnServerEvent automatically passes the client that fired the remote event; that is why it is printing a player object. xInfinityBear 1777 — 1y
0
@xInfinityBear ty NeoDogez 18 — 1y
0
but is there any way to fix this? NeoDogez 18 — 1y
0
Just put 'player' as the first parameter; the rest would be what you manually pass from the client, such as 'dogecoin'. xInfinityBear 1777 — 1y

Answer this question