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

How do i make a ScreenGui apear when a player steps on a brick?

Asked by 5 years ago

i have been trying to do this for a while but every tutorial on youtube does not work and i need help i dont know how to do this but this is the last script i entered

script.Parent.Touched:connect(function(hit)

if hit.Parent:FindFirstChild("Humanoid") then

game.Players.LocalPlayer.ScreenGui.Frame.Visible=true

end

end)

idk what to do for this and its really annoying going from tutorial after tutorial and them not working. if somebody can get me a working script that would be really helpful

0
btw im trying to make a simulator shop MPforfun 91 — 5y
0
Make sure you're using a local script for this and if you're going find the frame the way you're finding it instead of "game.Players.LocalPlayer.ScreenGui.Frame.Visible = true" do "game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Visible = true" songboy50 77 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

General Practice

ScreenGui s should be placed inside the StarterGui, where they will be relocated in-game to the PlayerGui under the Player

Use :WaitForChild() to make sure a part exists before using / changing it

Issues

connect is deprecated in favor of Connect

Server Scripts cannot call the LocalPlayer, and cannot access / read from the PlayerGui, you need to use a LocalScript instead.

Revised LocalScript under the ScreenGui

local player = game:GetService("Players").LocalPlayer
local part = workspace:WaitForChild("ShopPart")

part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild(“Humanoid”) then
        script.Parent:WaitForChild("Frame").Visible = true
    end
end)

In the above example, the part that connects the function is a part under the Workspace named "ShopPart"

Ad

Answer this question