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

How to change the players properties if a BoolValue is true?

Asked by 10 years ago

Hello, I am making this game and its main genre is Health care and so on. Here is what i have done so far:

I made a model and named it "Sickness". It's parent is game (game.Sickness) and inside the Model there are 6 BoolValues. The name of the BoolValues are as shown below:

BoolValue 1 - Frostbite, BoolValue 2 - Radioactvity, BoolValue 3 - Nausea, BoolValue 4 - Fatigue, BoolValue 5 - Fever, BoolValue 6 - Werewolfia,

I also have a SickScript for these BoolValues, Each BoolValue has a different impact on the player. The SickScript is also in game (game.SickScript). Here is the SickScript:

game.Players.PlayerAdded:connect(function(player) 

if player then
    print("Player is " .. player.Name)

    if player.Sickness.Frostbite.Value == true then
        while player.Sickness.Frostbite.Value == true do
            player.Character.Humanoid.WalkSpeed = 14
            player.Character.Head.BrickColor = BrickColor.new("Light blue")
    if player.Sickness.Frostbite.Value == false then
                break

    elseif player.Sickness.Radioactivity.Value == true then
        while player.Sickness.Radioactivity.Value == true do
            player.Character.Head.BrickColor = BrickColor.new("Sand green")
            z = Instance.new("Smoke", player.Character.Torso)
            z.Color = Color3.new(129/255, 170/255, 129/255)
            z.Opacity = 0.2
            z.Size = 0.5
            if player.Sickness.Radioactivity.Value == false then
                break

    elseif player.Sickness.Nausea.Value == true then
        while player.Sickness.Nausea.Value == true do
            player.Character.Head.BrickColor = BrickColor.new("Sand green")
            player.Character.Head.face.Texture = "http://www.roblox.com/asset/?id=26774915"
        while true do
            x = Instance.new("Part")
            x.Parent = player.Character
            x.Name = "Vomit"
            x.Material = "Slate"
            x.Formfactor = "Custom"
            x.Size = Vector3.new(0.5, 0.5, 0.8)
            wait(0.5)
            for i = 1, 6 do
            x:clone()
            wait(5)
            x.remove()
            wait(120)
        if player.Sickness.Nausea.Value == false then
                break

        elseif player.Sickness.Fatigue.Value == true then
        while player.Sickness.Fatigue.Value == true do
            player.Character.Head.BrickColor = BrickColor.new("Pastel yellow")
        while true do
            wait(60)            
            player.Character.Humanoid.PlatformStand = true
            wait(10)
            player.Character.Humanoid.PlatformStand = false
            wait(60)
        if player.Sickness.Fatigue.Value == false then
                break       

        elseif player.Sickness.Fever.Value == true then
        while player.Sickness.Fever.Value == true do
            player.Character.Head.BrickColor = BrickColor.new("Medium red")
            player.Character.Humanoid.WalkSpeed = 14
            player.Character.Head.Mesh.Scale = Vector3.new(1.5, 1.5, 1.5)
        if player.Sickness.Fever.Value == false then
                break   

        elseif player.Sickness.Fever.Value == true then
        while player.Sickness.Fever.Value == true do
            player.Character.Head.BrickColor = BrickColor.new("Medium red")
            player.Character.Humanoid.WalkSpeed = 14
            player.Character.Head.Mesh.Scale = Vector3.new(1.5, 1.5, 1.5)
        if player.Sickness.Fever.Value == false then
                break               

        elseif player.Sickness.Werewolfia.Value == true then
        while player.Sickness.Werewolfia.Value == true do
            player.Character.Humanoid.WalkSpeed = 20
            game.Lighting.PlayerWolfPackage:GetChildren()clone().Parent = player.Character  
            game.Lighting.LinkedSword:clone().Parent = player.Backpack
        if player.Sickness.Werewolfia.Value == false then
            v = player.Character:FindFirstChild("Werewolf Left Arm" and "Werewolf Right Arm" and "Werewolf Left Leg" and "Werewolf Right Leg" and "Werewolf torso")
            v:remove()
            player.Character.Humanoid.WalkSpeed = 16
            game.Lighting.PlayerDefaultPackage:GetChildren()clone().Parent = player.Character
            player.Backpack:FindFirstChild("LinkedSword"):remove()
                break

end end end end end end end end end end end end end end end end end end end end)


for _, player in pairs(game.Players:GetPlayers()) do PlayerAdded(player) end

A Model of BoolValue's are in player, if a BoolValue's Value is true then it wuld change the head color, walkspeed, head face, Etc. But this script has no errors so could you please fix it?

Thanks - GingerBiscuit99

1 answer

Log in to vote
0
Answered by
jobro13 980 Moderation Voter
10 years ago

Your ends are placed wrong!

Currently it checks if the player has frostbite - if not, it will jump out of the whole loop and not check anything else. Let me fix those ends...

game.Players.PlayerAdded:connect(function(player) 

if player then
    while true do -- forever sick checking loop
    print("Player is " .. player.Name)

    if player.Sickness.Frostbite.Value == true then
        while player.Sickness.Frostbite.Value == true do
            player.Character.Humanoid.WalkSpeed = 14
            player.Character.Head.BrickColor = BrickColor.new("Light blue")
    --  if player.Sickness.Frostbite.Value == false then
       --         break This is not necessary: the while loop wil check after the loop if it is true, if not, it is false and it will not re-run the loop. (breaking). However, you should include a wait() to prevent CPU exhaustion.
    wait()
    end

    elseif player.Sickness.Radioactivity.Value == true then
        while player.Sickness.Radioactivity.Value == true do
            player.Character.Head.BrickColor = BrickColor.new("Sand green")
            z = Instance.new("Smoke", player.Character.Torso)
            z.Color = Color3.new(129/255, 170/255, 129/255)
            z.Opacity = 0.2
            z.Size = 0.5
            wait()
    end

    elseif player.Sickness.Nausea.Value == true then
        while player.Sickness.Nausea.Value == true do
            player.Character.Head.BrickColor = BrickColor.new("Sand green")
            player.Character.Head.face.Texture = "http://www.roblox.com/asset/?id=26774915"
        while true do
            x = Instance.new("Part")
            x.Parent = player.Character
            x.Name = "Vomit"
            x.Material = "Slate"
            x.Formfactor = "Custom"
            x.Size = Vector3.new(0.5, 0.5, 0.8)
            wait(0.5)
            for i = 1, 6 do
            x:clone()
            wait(5)
            x.remove()
            wait(120)
        if player.Sickness.Nausea.Value == false then
                break
    end
end
        elseif player.Sickness.Fatigue.Value == true then
        while player.Sickness.Fatigue.Value == true do
            player.Character.Head.BrickColor = BrickColor.new("Pastel yellow")
        while true do
            wait(60)            
            player.Character.Humanoid.PlatformStand = true
            wait(10)
            player.Character.Humanoid.PlatformStand = false
            wait(60)
        if player.Sickness.Fatigue.Value == false then
                break       
    end
    end

        elseif player.Sickness.Fever.Value == true then
        while player.Sickness.Fever.Value == true do
            player.Character.Head.BrickColor = BrickColor.new("Medium red")
            player.Character.Humanoid.WalkSpeed = 14
            player.Character.Head.Mesh.Scale = Vector3.new(1.5, 1.5, 1.5)
            wait()
    end

        elseif player.Sickness.Fever.Value == true then
        while player.Sickness.Fever.Value == true do
            player.Character.Head.BrickColor = BrickColor.new("Medium red")
            player.Character.Humanoid.WalkSpeed = 14
            player.Character.Head.Mesh.Scale = Vector3.new(1.5, 1.5, 1.5)
    end

        elseif player.Sickness.Werewolfia.Value == true then
        while player.Sickness.Werewolfia.Value == true do
            player.Character.Humanoid.WalkSpeed = 20
            game.Lighting.PlayerWolfPackage:GetChildren()clone().Parent = player.Character  
            game.Lighting.LinkedSword:clone().Parent = player.Backpack
        if player.Sickness.Werewolfia.Value == false then
            v = player.Character:FindFirstChild("Werewolf Left Arm" and "Werewolf Right Arm" and "Werewolf Left Leg" and "Werewolf Right Leg" and "Werewolf torso")
            v:remove()
            player.Character.Humanoid.WalkSpeed = 16
            game.Lighting.PlayerDefaultPackage:GetChildren()clone().Parent = player.Character
            player.Backpack:FindFirstChild("LinkedSword"):remove()
                break
    end
    wait()
    end
    end

    end
    end

end)


for _, player in pairs(game.Players:GetPlayers()) do PlayerAdded(player) end

Your code did not error because the syntax was correct. However, your code blocks where off - a logic error, which is harder to debug :)

0
The Erros keeps saying "eof" GingerBiscuit99 30 — 10y
Ad

Answer this question