I inserted a part and placed my gui inside it, I put a script inside my gui to set it to playergui ontouch but nothing works, is this an issue with the script or gui
Here's the guigiver script
local debounce = false
function getPlayer(humanoid)
local players = game.Players:children()
for i = 1, #players do
if players[i].Character.Humanoid == humanoid then return players[i] end
end
return nil
end
function onTouch(part)
local human = part.Parent:findFirstChild("Humanoid")
if (human ~= nil) and debounce == false then
debounce = true
local player = getPlayer(human)
if (player == nil) then return end
script.Parent:clone().Parent = player.PlayerGui
wait(2)
debounce = false
player.PlayerGui.OnTouchGui:remove()
wait()
debounce = false
wait(5)
end
end
script.Parent.Parent.Touched:connect(onTouch)
And here's the maingui
sp = script.Parent
Frame = sp:WaitForChild("Frame")
Boss = Frame:WaitForChild("Boss")
Health = Frame:WaitForChild("Health")
Red = Frame:WaitForChild("Red")
HealthCount = Frame:WaitForChild("HealthCount")
BossName = Frame:WaitForChild("BossName")
Humanoid = nil
while true do
if Boss.Value ~= nil then
if Boss.Value:FindFirstChild("Torso") then
sp.BossGui.Adornee = Boss.Value.Torso
sp.BossGui.Enabled = true
end
Frame.Visible = true
BossName.Text = Boss.Value.Name
Humanoid = Boss.Value:FindFirstChild("Humanoid")
if Humanoid then
Health.Size = UDim2.new(Humanoid.Health/Humanoid.MaxHealth,0,1,0)
if Red.Size.X.Scale > Health.Size.X.Scale then
Red:TweenSize(UDim2.new(Humanoid.Health/Humanoid.MaxHealth,0,1,0), 1, 1, (Red.Size.X.Scale-Health.Size.X.Scale)*10, true)
else
Red.Size = UDim2.new(Humanoid.Health/Humanoid.MaxHealth,0,1,0)
end
HealthCount.Text = math.floor(Humanoid.Health).." | "..Humanoid.MaxHealth
--Health.BackgroundColor3 = Color3.new(1-(Humanoid.Health/Humanoid.MaxHealth),Humanoid.Health/Humanoid.MaxHealth,0)
else
sp.BossGui.Adornee = nil
sp.BossGui.Enabled = false
Frame.Visible = false
end
if Boss.Value.Parent == nil then
Boss.Value = nil
sp.BossGui.Adornee = nil
sp.BossGui.Enabled = false
Frame.Visible = false
end
else
sp.BossGui.Adornee = nil
sp.BossGui.Enabled = false
Frame.Visible = false
end
wait()
end
Any ideas on issues?

1 comment
Always check your output! What was the error it gave you?