#having trouble with :GetTouchingParts()

6 messages · Page 1 of 1 (latest)

feral cave
#

Hi, I'm new to scripting and I'm trying to make a king of the hill like game for practice.

So I want to check if a player is touching a part, and if he is every second he will get 1 point, now the problem is that if the player stands still he won't get points if I'm using .Touched event.
That's why I'm trying to use :GetTouching() function but it's not detecting when I touch the part.

this was my first script:

local plate = script.Parent
local Players = game:GetService("Players")

plate.Touched:Connect(function(hit)
    local humanoid = hit.Parent:FindFirstChild("Humanoid")
    if humanoid then
        local plr = hit.Parent
        local playerFromCharacter = Players:GetPlayerFromCharacter(plr)
        local canGetPoints = playerFromCharacter.canGetPoints
        if canGetPoints.Value == true then
            playerFromCharacter.leaderstats.Points.Value += 1
            canGetPoints.Value = false
            wait(1)
            canGetPoints.Value = true
        end
    end
end)

this is my current script which isn't working(it's only detecting when the baseplate is touching it)

local plate = script.Parent
local Players = game:GetService("Players")
while true do
    
    wait ()
    local parts = plate:GetTouchingParts()
    for i = 1, #parts do
        local part = parts[i]
        if part.Parent:FindFirstChild("Humanoid") then
            local plr = part.Parent
            local playerFromCharacter = Players:GetPlayerFromCharacter(plr)
            local canGetPoints = playerFromCharacter.canGetPoints
            
            if canGetPoints.Value == true then
                playerFromCharacter.leaderstats.Points.Value += 1
                canGetPoints.Value = false
                wait(1)
                canGetPoints.Value = true
                
            end
        end
    end
end
feral cave
#

Correct me of I'm wrong but doesn't the event only fires when the player moves once, after that it is impossible for the same event to see if the player is still touching the part

#

@mortal sorrel

feral cave
#

I don't think the .touching event knows how long im touching if im standing still

#

Like theres no possible way

sacred gust
#

workspace:getpartsboundinbox