Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
lucas4114 607 Moderation Voter
9 years ago

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

Log in to vote
1
Answered by 9 years ago
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)
Ad

Answer this question