You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
So I want to make a trading system. U can trade pets and other items.
What is the issue? Include screenshots / videos if possible!
I have a little bit of a problem tho!
So basically I have a localscript inside of a textbutton. When you press this textbutton I want a request to pop up on the player’s screen that you want to trade with. I want to do this with remote events and bindable events. I’ll show you the script from the client and server now.
script.Parent.MouseButton1Click:Connect(function() --//my variables\\-- local PlayerGui = script.Parent.Parent.Parent.Parent.Parent.Parent local player1 = PlayerGui.Parent -- This is the player who sent the request local player2 = game.Players:FindFirstChild(script.Parent.Parent.Text) if player2 then print(player2.Name) end --//functions\\-- if player2 and player2:FindFirstChild("IsTrading") and player2:FindFirstChild("TradingDisabled") then if player2.IsTrading.Value == false and player2.TradingDisabled.Value == false then --//I'm just trying to make sure that everything exists before i set a variable to something inside a different player\\-- local Request = player2.PlayerGui.TradeRequest local SetTradeValues = game.ReplicatedStorage:WaitForChild("SetTradeValues") if Request then Request:Fire(player1.Name) -- ignore this event, it has nothing to do with the error SetTradeValues:FireServer(player1.Name, player2.Name) end end end end)
Now I’ll show you the server script and that’s also where the error is!
game.Players.PlayerAdded:Connect(function(player) --//new instances\\-- local IsTrading = Instance.new("BoolValue", player) IsTrading.Name = "IsTrading" local TradingDisabled = Instance.new("BoolValue", player) TradingDisabled.Name = "TradingDisabled" local Requester = Instance.new("StringValue", player) Requester.Name = "Requester" end) game.ReplicatedStorage:WaitForChild("SetTradeValues").OnServerEvent:Connect(function(player1name, player2name) print("Event arrived") local player1 = game.Players:FindFirstChild(player1name) local player2 = game.Players:FindFirstChild(player2name) print(player1.Name, player2.Name) -- It doesn't know what I mean with Name if player1 and player2 then -- And this function doesn't fire because it thinks Name is nil! player2.Requester.Value = player1.Name print(player1.Name .. "would like to trade you!") end end)
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I can’t really find any solutions for this. Maybe there are and I’m just blind.
How can I fix this error?
And why can’t it find the player in game.Players?
This my first ever post and I don’t know if it’s in the correct category, so sorry if I made any mistakes!