Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you set a GUI to visible = true through touched function?

Idk how to do it, I'm pretty new to scripting so. I don't have a script example, it's just a question. But anyway, here's my script, no errors its just not working

local part = game.Workspace.GunKill.Part
local gui = game.StarterGui.Deathgui.Frame
game.Players.PlayerAdded:Connect(function(plr)

part.Touched:Connect(function()
gui.Script.Disabled = false
part:Destroy()
	workspace.GunCock:Play()
	wait(5)
	workspace.Gunshot:Play()
	wait(2)
	plr:Kick("Ending 5, Killed Self")
end)
end)

GUI's script:

script.Parent.Visible = true

1 comment

0

Why are you running a part.Touched function inside a PlayerAdded function?

2 answers

✓ Accepted answer
script.Parent.Touched:connect(function(hit)
local plr = game.Players:FindFirstChild(hit.Parent.Name)
plr.PlayerGui.Deathgui.Frame.Script.Disabled = false
end)

not sure if you wanted to set a script to

disabled, just working off what you wrote

1 comment

0

Alr, thanks.

try this

partnamehere.Touched:Connect(function(hit)
       local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
       if plr then
               GUInamehere.Visible = true
       end
end

1 comment

0

that wouldn't work, you have to reference the current PlayerGui, not the startergui

This discussion is preserved as it was. New answers, comments, and votes are closed.