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

My script, to show a Gui when a player touches a part doesn't work?

So, I'm trying to make something that when the player walks into the "Hitbox" a Gui in the player's Guis, will turn visible, and then when they walk out it goes back to visible = false.

function inHitbox(thing)
	local player = game.Players:GetPlayerFromCharacter(thing)
	player.PlayerGui.GetInCarGui.TextLabel.Visible = true
	if script.Parent.Hitbox.TouchEnded then
		player.PlayerGui.GetInCarGui.TextLable.Visible = false
	end
end

script.Parent.Hitbox.Touched:connect(inHitbox)

It doesn't work..... Help me? I tryed other things and the output says nothing.

1 answer

✓ Accepted answer
script.Parent.Hitbox.Touched:connect(funciton(Part)
if Part.Parent and Part.Parent:findFirstChild("Humanoid") and game.Players:findFirstChild(Part.Parent.Name) then
local player = game.Players:GetPlayerFromCharacter(thing.Parent)
 player.PlayerGui.GetInCarGui.TextLabel.Visible = true
   repeat wait(0.1) until player:DistanceFromCharacter(script.Parent.Hitbox.Position)  > 0-- Put a number here
player.PlayerGui.GetInCarGui.TextLable.Visible = false
end
end)

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