Hi! So, I just started with this script (I've been playing around with different stuff for a bit) so I tried to make this script where if you stepped on it it would create a ScreenGui and place it in StarterGui. It does just that, however it will keep doing it each time I step on it. How do I make it only do it once?
function kill(part) local sc = Instance.new("ScreenGui", game.StarterGui) end script.Parent.Touched:connect(kill)
Hallo, laffydecious. Der beste Weg, dies zu tun wäre, um zu überprüfen, ob die ScreenGui ist bereits in StarterGui, werde ich einige Beispiel-Code unten bieten.
function kill(part) if not game.StarterGui:FindFirstChild('MyGUI') then local sg = Instance.new("ScreenGui", game.StarterGui) sg.Name = 'MyGUI' end end script.Parent.Touched:connect(kill)
local touched = false function kill(part) if not touched then -- checks if touched is false touched = true -- makes touched true meaning it wont run this code again unless touched is changed to false local sc = Instance.new("ScreenGui", game.StarterGui) end end script.Parent.Touched:connect(kill)