【发布时间】:2021-04-26 12:33:46
【问题描述】:
我很困惑。我正在努力做到这一点,如果你用 Roblox 的“ProximityPrompt”按住 E,你会在屏幕上看到一个带有一些文本的 GUI。一切正常,除了文本不起作用。我也没有在客户端脚本上写一个字符串。在传递过来的服务器脚本上有一个变量。但我一直在输出中看到这个错误。
Players.ford200000.PlayerGui.BuyGui.Frame.TextInput.Text:2:尝试将 nil 与字符串连接 - 客户端 -
这是我在脚本中所做的事情
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)
并且在监听 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)
请帮忙,将不胜感激。
【问题讨论】:
-
你能发布你的代码吗?
-
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)服务器脚本 -
game.ReplicatedStorage.ShopInfoEvent.OnClientEvent:Connect(function(player, price, item) script.Parent.Text = "Would you like to buy this ".. item.Name .." for ".. price.Value .."?" end)客户端脚本 -
@ford200000 请不要在 cmets 中发布代码不好,因为您无法正确格式化它。相反,请编辑您的问题。