When i fire the event it print out : Value is a not valid member of player.
I want the script to decrease my health potion stats.
The Local script :
script.Parent.HugePot.TextButton.MouseButton1Click:Connect(function()
local plr = game.Players.LocalPlayer
local stat = game.Players.LocalPlayer.Potions.HugeHealthPot
game.ReplicatedStorage.PotUse:FireServer(plr, stat)
end)
In the Local Script, there’s no need to have plr as an argument for the Remote Function since it gets passed automatically anyway. Removing plr should fix your code.
Really, ...PotUse:FireServer(plr, stat) gets interpreted as ...PotUse:OnServerEvent:Connect(function(plr, plr, stat)) in the Server Script. Consequently, “stat” is actually “plr”, and plr doesn’t have a value which is why it causes an error.
(this is just nitpicking but you can write local stat = plr.Positions.HugeHealthPot since you’ve already written local plr = game.Players.LocalPlayer. )
I hope this helps! Feel free to ask any more questions.
This is because you dont need to give the server the plr in the arguments! the first argument given is always the player by default even if you dont give it any arguements!
Simply do game.ReplicatedStorage.PotUse:FireServer(stat)