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

TouchEnded triggers while player is still on part?

Asked by 6 years ago

When this player touches this pad the touchended function triggers, is there any ways to stop this?

script.Parent.Touched:Connect(function(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if isPlayerAlreadyInList(player) == false then
        local listlength = #nextup
        if listlength >= 3 then
            removeplayerfrompad(player)
        else
            table.insert(nextup,player.Name)
            table.insert(ready,0)
            padcolour()
            updateScreens()

        end
    end
end)

script.Parent.TouchEnded:Connect(function(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if game.Players:GetPlayerFromCharacter(hit.Parent) == player then
        if isPlayerAlreadyInList(player) == true then
            print(findItemPos(player.Name,nextup))
        end
    end     
end)
0
I use a custom magnitude script that isn't 100% accurate, but detects what part a player is touching. Chaddaking 60 — 6y

1 answer

Log in to vote
0
Answered by
Fifkee 2017 Community Moderator Moderation Voter
6 years ago

The .Touched and .TouchEnded function are very stupid. If you stand on a part for too long, the TouchEnded function may fire. If you land on a part, sometimes the Touch function may not fire at all. I'd recommend you use a small Region3 or .magnitude, because .Touched really shouldn't be used for long term. Maybe ROBLOX was being a nitpicker when developing, and only considered the touch event, but not when someone keeps touching the part. Heck, you could probably even use :GetTouchingParts() on a player's legs, it's probably more reliable than the .Touched event. Just, don't use the .Touched event on a basepart. It's extremely unreliable.

Ad

Answer this question