#Adding 1 to Collected value isn't working. It was working yesterday but now it doesn't.

4 messages · Page 1 of 1 (latest)

rotund flare
#

The touch event is firing; Things happen after as they are suppose to.

local part = script.Parent
local canget = true
local modularscript = require(game.ReplicatedStorage.RandomFunctionModual)

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
        
        local playercollectedvalue = player.leaderstats.Collected.Value
        
        canget = false
        
        playercollectedvalue = playercollectedvalue + 1
        player.Touched_Brick_Color.Value = part.BrickColor.Name --set player brick color
        
        if player.Touched_Brick_Color.Value == part.BrickColor.Name then --check brickcolors equal each other
            player.Multiplier.Value = player.Multiplier.Value + 1 --add to multiplier
        end
        
        modularscript.randomnumber()
        local ranX, ranZ
        ranX, ranZ = modularscript.randomnumber()
        
        part.Anchored = false
        part.Position = Vector3.new(ranX, 10.5, ranZ)
        part.BrickColor = BrickColor.random()
        part.Anchored = true
        wait(3)
        canget = true
    end
end 

end --function end

part.Touched:Connect(ontouch)

fathom fern
#

Explanation for you problem based on a similar case: #📜︱scripting message

#

If your code hasn't changed, it was never working