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

leaderstats not changing when I touch a part?

Asked by
zomspi 541 Moderation Voter
4 years ago

I am making a script where when I touch a part it changes other part's properties, then it is meant to change my leaderstats Stage Value to 1 if it is on 0 else do nothing, after that is some more propertie changing.

game:WaitForChild("Players").PlayerAdded:Connect(function(plr)
    script.Parent.Touched:Connect(function(hit)
        if game.Players:GetPlayerFromCharacter(hit.Parent) then
            if workspace:FindFirstChild("Walls", true) then
                local wall = workspace.Walls:FindFirstChild("Wall4", true)
                wall.CanCollide = true
                wall.BrickColor = BrickColor.new("Really red")
                script.Parent.CanCollide = false
                script.Parent.BrickColor = BrickColor.new("Really red")
                game.ReplicatedStorage.NightSky.Parent = game.Lighting

                if plr.leaderstats.Stage.Value >= 0  then
                    plr.leaderstats.Stage.Value = 1
                else

                end

                wait(15)
                if workspace:FindFirstChild("Walls", true) then
                     local Wall1 = workspace.Walls:FindFirstChild("Wall5", true)
                     Wall1.CanCollide = false
                     Wall1.BrickColor = BrickColor.new("Lime green")
                     game.Workspace.Enemies.Dark.Zombie.WalkSpeed = 0
                end
            end
end
end)
end)



0
The leaderstat part isn't working zomspi 541 — 4y
0
Try to pinpoint exactly what part of the script isn't working by adding print statement at certain parts - is the Part.Touched event even firing? any errors? be more specific in what is not working shadow7692 69 — 4y
0
The Part touched is working, everyhing is working except the leaderstat changing zomspi 541 — 4y

2 answers

Log in to vote
0
Answered by
G2001H 75
4 years ago
Edited 4 years ago

Idk if this work but you can try

script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if game.Workspace:FindFirstChild("Walls", true) then
        local wall = game.Workspace.Walls:FindFirstChild("Wall4", true)
        wall.CanCollide = true
        wall.BrickColor = BrickColor.new("Really red")
        script.Parent.CanCollide = false
        script.Parent.BrickColor = BrickColor.new("Really red")
        game.ReplicatedStorage.NightSky.Parent = game.Lighting
        if player:FindFirstChild("leaderstats").Stage.Value >= 0  then
        player:FindFirstChild("leaderstats").Stage.Value = 1
            wait(15)
            if game.Workspace:FindFirstChild("Walls", true) then
                local Wall1 = game.Workspace.Walls:FindFirstChild("Wall5", true)
                Wall1.CanCollide = false
                Wall1.BrickColor = BrickColor.new("Lime green")
                game.Workspace.Enemies.Dark.Zombie.WalkSpeed = 0
                end
            end
        end
    end
end)

0
unfortunately that didn't work zomspi 541 — 4y
0
this worked for me... G2001H 75 — 4y
Ad
Log in to vote
0
Answered by
zomspi 541 Moderation Voter
4 years ago

nvm I fixed it

Answer this question