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

How do I fix this script to remove the Gui when the player is not touching the part anymore?

Asked by
130363 67
7 years ago

In the output it states that attempt to call field 'TouchEnded' (a userdata value) if that helps and if possible >** put a script and explain what the script does so I can understand the script.**

script.Parent.TouchEnded(function(ended)
    local parent = ended.Parent
    local player = game.Players:GetPlayerFromCharacter(parent)

    if player then
        if player.PlayerGui:FindFistChild("TeleportGui") then
            player.PlayerGui.TeleportGui:Destroy()
        end
    end
end)

:)

1 answer

Log in to vote
0
Answered by 7 years ago

This should work. Let me know if it doesnt.

local touchPart = script.Parent
local deb = false

touchPart.TouchedEnded:connect(function(hit)

    if deb == false then deb = true
        if hit then
            local chr = hit.Parent
            local plr = game.Players:GetPlayerFromCharacter(chr)
            if plr.PlayerGui:FindFirstChild("TeleportGui") then
                plr.PlayerGui.TeleportGui:Remove()
            end
        end
    wait(1)
    deb = false
    end

end)

0
Oops I put 'TouchedEnded' instead of 'TouchEnded' Just change that and you should be gucci TickTockTheory 106 — 7y
0
This isn't a big problem but what do they mean by attempt to index local 'plr' (a nil value)? 130363 67 — 7y
Ad

Answer this question