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

Gui doesn't pop upon touch of brick?

Asked by 7 years ago
01script.Parent.Touched:Connect(function(HIT)
02    local player = game.Players:GetPlayerFromCharacter(HIT.Parent)
03    if player == game.Players.LocalPlayer then
04        player.PlayerGui.ScreenGui.Shop.Visible = true
05    end
06end)
07 
08script.Parent.TouchEnded:Connect(function(HIT)
09    local player = game.Players:GetPlayerFromCharacter(HIT.Parent)
10    if player == game.Players.LocalPlayer then
11        player.PlayerGui.ScreenGui.Shop.Visible = false
12    end
13end)

This is in a local script in a brick.

What is wrong here?

0
I have had this problem before too. I just made it a regular script in StarterGui with a player variable and a click detector to make it open. Example:                                         local plr = script.Parent.Parent local click = game.Workspace.ATM.Open.ClickDetector click.MouseClick:connect(function() plr.PlayerGui.ATM.Enabled = true end) PolyyDev 214 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Never use local scripts in parts. Even when It comes to touch events. Use a Server Script (Regular Script) instead.

0
Thank you! I'l remeber to keep that in mind form now on. User#17125 0 — 7y
Ad

Answer this question