Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make TextButton Visible when Part is hit?

Hi! I'm trying to make an Obstacle course and when you complete a stage/floor and you step on the checkpoint, in an open/close GUI, a TextButton appears saying Floor1, Floor2, etc and when clicked on, it will teleport you to the desired stage that you have completed already. I have used the script below but the TextButton (Floor1 etc) isn't appearing when the checkpoint(part) is touched. Please help. If you need more information, reply to this question.

script.Parent.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
	    game.Players.LocalPlayer.PlayerGui.LvlMenu.Frame.Floor1.Visible = true
    end
end)

I've also tried this:

script.Parent.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
	    game.StarterGui.LvlMenu.Frame.Floor1.Visible = true
    end
end)

1 answer

✓ Accepted answer

There's a couple of problems with your script.

Firstly, you're changing properties of childs inside of a Player from a ServerScript which is a huge no-no. You should always change properties within a player using a LocalScript.

Secondly, ":connected" is deprecated and will soon be removed. Use ":Connect" instead.

Thirdly, use more ":FindFirstChild" and ":WaitForChild". Store the path in variables one by one to make sure your script will never error.

Fourthly, it may not be the script's problem. Check your Explorer and see if your GUI is correctly positioned.

About the second script, changes in StarterGui won't replicate to players in real time. They will only apply when they respawn and it will apply to all players. (If changed from ServerScripts)

Hopefully this can fix your problem.

1 comment

0

I'll see what I can do, Thanks. Also i did use :connect. The GUI is in the right place.

This discussion is preserved as it was. New answers, comments, and votes are closed.