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

Fireing multiple paramaters through server event issues.Can somebody help me?

Asked by 2 years ago

Hello, I'm having issues with sending multiple parameters trough a server event. It just doesn't works, and I'm suffering because of this problem. Here are the scripts:

local script:

local wood = Inv.Materials.Wood
local oldWood = 0

wood.Changed:Connect(function(player,newv)
    print(oldWood)
    local event = game.ReplicatedStorage.Inventory.Wood
    event:FireServer(newv,oldWood)
    wait()
    oldWood = newv
end)

server script:

local Inventory = game.ReplicatedStorage.Inventory
local wood = Inventory.Wood

wood.onServerEvent:Connect(function(player,newv,old_Wood)


    print(newv) --123
    print(old_Wood)  --124
    local value = newv - old_Wood

    print(player.."'s just got "..value.." Wood! Now he has "..newv.." Wood.")


end)

Output: 17:40:49.263 nil - Server - Inventory:123 17:40:49.263 0 - Server - Inventory:124

1 answer

Log in to vote
2
Answered by
imKirda 4491 Moderation Voter Community Moderator
2 years ago

Documentation for IntValue.Changed says that this event has only one parameter and that is the new value, you are expecting it to have 2 parameters where the first one is the player, this is not correct.

wood.Changed:Connect(function(player,newv)
    print(player, newv)
end)

Example above will print you message in format:

number nil

You can fix this by having only single parameter in the function:

wood.Changed:Connect(function(newv)
0
So I cant get a variable trough the fireserver, only a parameter? mittomen28 5 — 2y
0
Tho, the oldvalue is working, I have issues with the newvalue (newv) mittomen28 5 — 2y
0
Sry, i didn't notice that I had the player in the change function's parameters. mittomen28 5 — 2y
0
parameters are same variables, they both hold values and you can pass them to :FireServer, what exact issues are you having right now? ~~~~~~ oki oki imKirda 4491 — 2y
Ad

Answer this question