Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
1ov3y0u 51
5 years ago
Edited 5 years ago

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

01local part = game.Workspace.GunKill.Part
02local gui = game.StarterGui.Deathgui.Frame
03game.Players.PlayerAdded:Connect(function(plr)
04 
05part.Touched:Connect(function()
06gui.Script.Disabled = false
07part:Destroy()
08    workspace.GunCock:Play()
09    wait(5)
10    workspace.Gunshot:Play()
11    wait(2)
12    plr:Kick("Ending 5, Killed Self")
13end)
14end)

GUI's script:

1script.Parent.Visible = true
0
Why are you running a part.Touched function inside a PlayerAdded function? XxTrueDemonxX 362 — 5y

2 answers

Log in to vote
1
Answered by
Robowon1 323 Moderation Voter
5 years ago
1script.Parent.Touched:connect(function(hit)
2local plr = game.Players:FindFirstChild(hit.Parent.Name)
3plr.PlayerGui.Deathgui.Frame.Script.Disabled = false
4end)

not sure if you wanted to set a script to

disabled, just working off what you wrote

0
Alr, thanks. 1ov3y0u 51 — 5y
Ad
Log in to vote
0
Answered by
Loot_O 42
5 years ago

try this

1partnamehere.Touched:Connect(function(hit)
2       local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
3       if plr then
4               GUInamehere.Visible = true
5       end
6end
0
that wouldn't work, you have to reference the current PlayerGui, not the startergui Robowon1 323 — 5y

Answer this question