[英]Are you able to add code for other text buttons with a local script inside somewhere else in Luau?
所以我在 Luau 中用 gui 制作了一个 cookie 唱首歌,我试图做到这一点,所以当你点击一个按钮时,它会带走 cookies 并添加一个乘数,但脚本在 cookie 按钮内
local cookies = 0
local plr = game.Players.LocalPlayer
local clickMultiplyer = 1
script.Parent.MouseButton1Click:Connect(function()
cookies = cookies + cm
plr.PlayerGui.CookiesDisplayText.Text = cookies
end
--This first part works just fine--
plr.PlayerGui.ShopUi.BuyButton:Connect(function()
if cookies == 100 or cookies =< 100 then
cookies = cookies - 100
cm = cm + 1
else
plr.PlayerGui.ShopUi.BuyButton.Text = "not enough cash"
wait(.5)
plr.PlayerGui.ShopUi.BuyButton.Text = "Buy cost:100 +1 clickmultiplyer"
end
end
没有错误,但它根本不起作用,提前谢谢你:))
我修复了 vs code 和 roblox 检测到的所有错误。
它的拼写是“乘数”。 对于同一件事,您有两个变量。 这应该有效,假设其他一切都设置正确。
local cookies = 0
local plr = game.Players.LocalPlayer
local multiplier = 1
script.Parent.MouseButton1Click:Connect(function()
cookies += multiplier
-- This may cause issues, a TextLabel inside of PlayerGui should not be visible unless it's parented to a ScreenGui
plr.PlayerGui.CookiesDisplayText.Text = cookies
end
plr.PlayerGui.ShopUi.BuyButton:Connect(function()
if cookies >= 100 then
cookies -= 100
cm += 1
else
plr.PlayerGui.ShopUi.BuyButton.Text = "not enough cash"
task.wait(.5)
plr.PlayerGui.ShopUi.BuyButton.Text = "Buy cost:100 +1 clickmultiplier"
end
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.