Hello! I'm trying to make GUI appear when I touch block. I did this script below but it doesn't works, also I don't have any errors, any ideas what should I change? (script is in local script)
local Player = game.Players.LocalPlayer local function change(hit) if hit.Parent and hit.Parent:FindFirstChild("Humanoid") then Player.PlayerGui.UniformGui.Frame.Visible=true end end script.Parent.Touched:Connect(change)
The problem is that you're using a local script, local scripts don't work in the workspace. I'd suggest using a normal script and putting your GUI inside of the script, and when you touch the brick simply clone the GUI into the player's PlayerGui folder by doing something like this:
local gui = script.gui -- change this to wherever your GUI is script.Parent.Touched:Connect(function (hit) if hit.Parent and hit.Parent:FindFirstChild("Humanoid") then gui:Clone() -- Clones the GUI local playerName = hit.Parent.Name local player = game.Players[playerName] gui.Parent = player.PlayerGui -- Puts the GUI in the player's PlayerGui Folder end end)
I'm not an expert in scripting, and if anyone has a better solution or sees any errors in my answer, feel free to comment! ;)
It seems you have your local script inside workspace. The reason why it doesn't work is because local scripts don't work inside workspace. Local scripts will only run if they are a descendant of either a Player's Backpack, Character model, PlayerGui, PlayerScripts or the ReplicatedFirst service.
To fix this you would simply just need to parent the local script somewhere that was stated above.