I'm very confused. I'm trying to make it so that if you hold E with Roblox's "ProximityPrompt", you will get a GUI on your screen with some text. Everything works except that the text won't appear. I also am not writing a string on the client script. There is a variable for it on the server script that gets passed over. But I keep seeing this error in the output:
Players.ford200000.PlayerGui.BuyGui.Frame.TextInput.Text:2: attempt to concatenate nil with string - Client -
Here is what I'm doing in my script
local sp = script.Parent
sp.ProximityPrompt.Triggered:Connect(function(player)
local name = sp.Name
local ss = game.ServerStorage
local item = ss.Hats:FindFirstChild(name)
local price = item.Price
game.ReplicatedStorage.ShopClickEvent:FireClient(player)
game.ReplicatedStorage.ShopInfoEvent:FireClient(player)
end)
And in the local script that listens for ShopInfoEvent
game.ReplicatedStorage.ShopInfoEvent.OnClientEvent:Connect(function(player, price, item)
script.Parent.Text = "Would you like to buy this ".. item.Name .." for ".. price.Value .."?"
end)
Please help, that would be greatly appreciated.
Your error is telling you that the object you are trying to add to a string is undefined.
This could be item.Name
or price.Value
is undefined and causing this string construction to fail.
Looking at how you are defining item
and price
shows that both of these values are undefined in your LocalScript's callback. When you call a RemoteEvent's FireClient function, the first argument tells the engine who to send the event to, and all the other arguments get passed in as the arguments of the callback. Currently, you aren't passing in any arguments at all.
So to fix your problem, you need to pass in the right arguments from the Script:
game.ReplicatedStorage.ShopInfoEvent:FireClient(player, price, item)
and parse them properly in your LocalScript :
game.ReplicatedStorage.ShopInfoEvent.OnClientEvent:Connect(function(price, item)
script.Parent.Text = "Would you like to buy this ".. item.Name .." for ".. tostring(price.Value) .."?"
end)