So, I am making a shop and that when you press the button in a gui, it sends a remote event to a server with the player, the character, and the weapon the player wants to buy. However, in the local script, weapon = GoldSword which is what I want it to but when it goes to the server script it equals the player. Why is this?
The localscript
local plr = game.Players.LocalPlayer local char = plr.Character local ReplicatedStorage = game:GetService("ReplicatedStorage") local Purchase = ReplicatedStorage:WaitForChild("PurchaseWeapon") local Weapon = script.Parent.Tool.Value function leftClick() print(Weapon) game.ReplicatedStorage:FindFirstChild("PurchaseWeapon"):FireServer(char, plr, Weapon) end function onTouchTap() game.ReplicatedStorage:FindFirstChild("PurchaseWeapon"):FireServer(char, plr, Weapon) end script.Parent.MouseButton1Click:Connect(leftClick) script.Parent.TouchTap:Connect(onTouchTap)
Serverscript
game.ReplicatedStorage.PurchaseWeapon.OnServerEvent:Connect(function(plr,char,Weapon) local Cost = Weapon.Price.Value if Cost > plr.Gold.Value or plr.Backpack:FindFirstChild(Weapon) or char:FindFirstChild(Weapon) then plr.Gold.Value = plr.Gold.Value else plr.Gold.Value = plr.Gold.Value - Cost Weapon:Clone().Parent = plr.Backpack end end)
Correct me if I'm wrong, but I believe that the "Player" value is automatically sent if you dont add it, which means right now, your doing something along the lines of
FireServer(player, char, plr, Weapon)
So what you probably should do is something like this inside the script instead
FireServer(char, Weapon)
and then you send 3 values. Player, Character, and Weapon
and then in the server script, what should work is
OnServerEvent:Connect(function(plr,char,Weapon)
which is what you wrote, I'm just trying to make sure I'm understandable.
Sorry in advance if I'm incorrect!
That's all, have a nice day!