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

Why is it printing the wrong Parmaters, which is causing the whole script to error?

im am making a stat gui with in creases the players attack, deffenc, and stamina (which are all int Values in side a Folder named "Stats")

when I click the button , 3 parematers shall be sent to the server which is the...

player's name stat to update the amount to give

but when I print the paramaters on the server side it says this...

Tizzel40 Tizzel40 Attack

here is the local script...

local statsframe = script.Parent

local addAttackb = statsframe.AddAttackButton

local addDefb = statsframe.AddDeffenceButton

local addStaminab = statsframe.StaminaLabel

local addattackrem = game.ReplicatedStorage:WaitForChild("NetworkFolder").AddStats

local play = game.Players.LocalPlayer

local playerstats = play:WaitForChild("Stats")

local amount = 1

local plrname = play.Name

local stattoupdate = "Attack"


addAttackb.MouseButton1Click:Connect(function()
	addattackrem:FireServer(plrname,stattoupdate,amount)
			

end)

and then here is the server script located in serverstorage

local remote = game.ReplicatedStorage:WaitForChild("NetworkFolder").AddStats




remote.OnServerEvent:Connect(function(playername,stattoupdate,amount)
	
	print(playername)
	 print(stattoupdate)
	print(amount)
	if game.Players[playername]  ~= nil then
		print("Verifiction passed #1")
		if game.Players:WaitForChild(playername).Stats ~= nil then
			print("Verifiction passed #2")
			if game.Players:WaitForChild(playername).Stats[stattoupdate].Value > 0 then
				print("Verifiction passed #3")
				
		--		
				game.Players:WaitForChild(playername).Stats:WaitForChild("StatPoints").Value = game.Players:WaitForChild(playername).Stats:WaitForChild("StatPoints").Value - 1
				game.Players:WaitForChild(playername).Stats[stattoupdate].Value = game.Players:WaitForChild(playername).Stats[stattoupdate].Value + amount
			else
				print(playername.."has an Insufficient amount of stat Points and Failed to Increase their "..stattoupdate.."!")
			end
		end
	end
	

	
	
end)

please help me!?

5 comments

0

Don't include the plrname argument when you fire the event, it includes the player as a parameter automatically.

0

The Printing Starts happening on lines number 8,9,and 10 on the "Server Sided Script"!

0

Ooof. You are going to have to explain a bit more clearly. also, please give us the script. It is hard to visualize what you are doing.

0

huh i did give you the script...?

0

and Azarth what do you mean about sending the name, i need to send the name!?

1 answer

✓ Accepted answer

You don't have to include the plrname argument.

addattackrem:FireServer(stattoupdate,amount)

It will send the LocalPlayer as a parameter automatically.

remote.OnServerEvent:Connect(function(player,stattoupdate,amount)
	print(player.Name)
end)

1 comment

1

THANK YOU Azarth!!! :D man I wish I can upvote you lol XD :D!!! wow....

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