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

use a touched event in a local script?

I want to make a script where if a player touches a certain block then a screen gui appears only for them. This is a script I've tried to make but it won't work since it's a local script:

player = game.Player.LocalPlayer

script.Parent.Touched:connect(function(hit)
	game.StarterGui.ScreenGui.Enabled = true
	wait(5)
	game.StarterGui.ScreenGui.Enabled = false
end

it's a pretty simple concept and I'm sure there's something better I could use and I would really appreciate if someone taught me what it is. :)

1 answer

✓ Accepted answer

By your coding I am judging you're a beginner, here, fixed:

local player = game.Players.LocalPlayer

workspace.Part.Touched:connect(function(hit)
    player.PlayerGui.ScreenGui.Enabled = true
    wait(5)
    player.PlayerGui.ScreenGui.Enabled = true
end)

Put it in a LocalScript in StarterGui or StarterPack

1 comment

0

haha thank you I will keep that in mind next time I try to access the gui's :)

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