So here's the story, whenever a character touches a brick, I want the gui to change text/transparency, however I do not know what is wrong with my script.
script.Parent.Touched:Connect(function() game.StarterGui.ScreenGui.Frame.TextLabel.Text = "hellloooo" end)
The script in the brick ^^^
Hello.
The reason as to why you aren't seeing changes to the Frame text, is because you are changing the frame in the StarterGui, instead of the PlayerGui. The StarterGui is different compared to the PlayerGui for a very important reason. The StarterGui, as said in it's name, is what gives the player the Guis when they join, and the PlayerGui, also said in it's name, is the Guis present in the Player.
To make changes to the gui, you are required to change the gui from the PlayerGui instead. So with your script, assuming it's a serverscript, you need to get the player via the Touched function, simply done with a Players:GetPlayerFromCharacter(hit.Parent). We tend to use a hit function for the touched function, as it's used to define the player.
Now let's take your script and apply these changes:
local Players = game:GetService("Players") -- Get the players local Part = script.Parent -- Gets the part that needs to be touched Part.Touched:Connect(function(hit) -- Set the hit function local Player = Players:GetPlayerFromCharacter(hit.Parent) -- Get the LocalPlayer via the touched event local PlayerGui = Player:WaitForChild("PlayerGui") -- Get the PlayerGui PlayerGui.ScreenGui.Frame.TextLabel.Text = "hellloooo" -- Set the text from the gui in PlayerGui end)
Hope this helps!
No, you also have to make sure if a player touched the part:
local Part = script.Parent
Part.Touched:Connect(function(hit) local hum = hit.Parent:FindFirstChild("Humanoid") if hum then -- Do whatever the person on top of me did
end)