Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

4 comments

0

So I cant get a variable trough the fireserver, only a parameter?

0

Tho, the oldvalue is working, I have issues with the newvalue (newv)

0

Sry, i didn't notice that I had the player in the change function's parameters.

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

This discussion is preserved as it was. New answers, comments, and votes are closed.