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

use a touched event in a local script?

Asked by 5 years ago
Edited 5 years ago

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

Log in to vote
0
Answered by
1GlF 42
5 years ago

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

0
haha thank you I will keep that in mind next time I try to access the gui's :) retracee 68 — 5y
Ad

Answer this question