Hey!
I’m trying to make a script that when a player touches a part, then gui opens for everyone, not just for the player that touched the part. (It would open for everyone so that everyone knows that this specific person touched the part)
I also wanted it to activate a kill script when the part is being touched.
Kill script does activate and the whole script works, except the gui part of it. The gui does not open. I’ve tried enabling the gui, then keeping gui enabled and tried making the frame visible instead, but none of these seem to work. I also don’t want to use LocalScript, since I want everyone to see the gui.
I’m pretty new to scripting, so any help would be appreciated!
I’ve looked for solutions in DevForum, but they just want the gui to appear for 1 person. I want the whole server to see it.
My current script:
script.Parent.Touched:Connect(function(hit)
for i,v in pairs(game.Players:GetPlayers())
if v.PlayerGui then
v.PlayerGui.win.Enabled = true
wait(5)
v.PlayerGui.win.Enabled = false
end
end
end)
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(3)
debounce = false
player.PlayerGui.win:remove()
wait()
debounce = false
wait(5)
end
end
script.Parent.Parent.Touched:connect(onTouch)
all you have to do is move your gui into part and add scripts to the gui