Allow multiple players who touched a part to get a point

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to make it so that however many players touched a part, it will give a point to them all.
  2. What is the issue? Include screenshots / videos if possible!
    Currently, it gives a point to only 1 player who touches the point.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I couldn’t find anything on multiple players touching a part, but I tried to make a table for players touching a part, it isn’t working however.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local levels = workspace:GetDescendants()
for i, child in pairs(levels) do
    if child:IsA("BasePart") and child.Name == "GuessGiver" then
    local debounce = true
    child.Touched:Connect(function(hit)
        local plrstats = game:GetService('Players'):GetPlayerFromCharacter(hit.Parent)
        if plrstats and debounce then
            debounce = false
            plrstats.leaderstats.Guessed.Value = plrstats.leaderstats.Guessed.Value +1
            wait(2)
            debounce = true
            end
        end)
    end
end

You should make this a local script.

Also one reason why it only gives it to one person is that the player is touching the part before the debounce gets changed to true in

wait(2)

Just a thought.

I will try that thank you. So every player who touches a part, instead of the server keeping track the client would. But how would it update leaderstats that is on ServerScriptService? If I’m not mistaken, localscripts can’t access certain things.

I am pretty sure you can access leaderstats using local scripts but I may be mistaken as it is a long time since I have done that lol.

Using a RemoteEvent, you can fire it from the local script and have a server script that listens when the RemoteEvent is fired and change the leaderstats.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.