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

What is wrong with this script

i want to make a GUI button that becomes visible when a button in workspace is touched by you. I wrote this script and it doesn't work!

function onTouched (part)
	game.StarterGui.GUIMessage.Message.Visible = true
end
script.Parent.Touch:connect(onTouched)

that script is in the part that needs to be touched the button that i want to be made visible is called message

if this is inpossible can you tell me how to make a script that makes a new instance of a screen GUI and button GUI (with certain position size and text) by stepping on a part

1 answer

✓ Accepted answer

The event is Touched, not Touch. Also, changing something in StarterGui will only affect newly received GUI's and not the one the player has.


script.Parent.Touched:connect(function(hit)
	if hit.Parent and hit.Parent:findFirstChild("Humanoid")  then
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		if plr and plr.PlayerGui:findFirstChild("GUIMessage") then
			plr.PlayerGui.GUIMessage.Message.Visible = true
		end
	end
end)

2 comments

0

thanks so much it worked

0

SirKitten, please mark this as the answer if it is correct.

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