i have guess the anime game and there is a problem with the points leaderstats, the problem is that when i go with my friend to the next stage at the same time its gives only point to one of us.
script:
local part = script.Parent
local canGet = true
local function onTouch(otherPart)
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
if humanoid then
local player = game.Players:FindFirstChild(otherPart.Parent.Name)
if player and canGet then
canGet = false
player.leaderstats.Points.Value = player.leaderstats.Points.Value + 1
wait(50)
canGet = true
end
end
end
part.Touched:Connect(onTouch)
It’s because of the canGet value, which is false after the first player touched it. The second player is able to get the point after the delay of 50 seconds.
I’m not an actual scripter, but this may work:
local part = script.Parent
local Players = game:GetService("Players")
local canGet = {}
local function onTouch(otherPart)
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
if humanoid then
local player = Players:GetPlayerFromCharacter(otherPart.Parent)
if player and not canGet[player.UserId] then
canGet[player.UserId] = true
player.leaderstats.Points.Value += 1
wait(50)
canGet[player.UserId] = nil
end
end
end
part.Touched:Connect(onTouch)