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 workspace (game.Workspace.SickScript). Here is the SickScript:

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
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
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:FindFirstChild("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

The Output:

21:36:51.043 - Sickness is not a valid member of Player 21:36:51.046 - Script 'Workspace.SickScript', Line 7 21:36:51.047 - stack end

2 answers

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

Even if you parented it to 'game'(Which I'm not sure how you did that..), you'd need a script to parent it to the player. So..

game.Players.PlayerAdded:connect(function(plr)
p = Instance.new("Model", plr)
p.Name = "Sickness"
a = Instance.new("BoolValue", p)
b = Instance.new("BoolValue", p)
c = Instance.new("BoolValue", p)
d = Instance.new("BoolValue", p)
e = Instance.new("BoolValue", p)
f = Instance.new("BoolValue", p)
a.Name = "Frostbite"
a.Value = false
b.Name = "Radioactivity"
b.Value = false
c.Name = "Nausea"
c.Value = false
d.Name = "Fatigue"
d.Value = false
e.Name = "Fever"
e.Value = false
f.Name = "Werewolfia"
f.Value = false
0
I used the following command in the command bar: game.ScriptName.parent = game GingerBiscuit99 30 — 10y
0
I would've never thought that that way would of work. Shawnyg 4330 — 10y
0
Hmm, It works fine for randomizing. But it just cannot find the Sickness Model inside of the player. #CONFUSED GingerBiscuit99 30 — 10y
0
Try parenting the model to their character. To keep it in there after they die, you'll need a Died event/function. Check out some FMs. Shawnyg 4330 — 10y
0
Okay, thanks. GingerBiscuit99 30 — 10y
Ad
Log in to vote
0
Answered by
Dominical 215 Moderation Voter
10 years ago

Maybe you need to add a BoolValue when a player joins. Try this:

function onPlayerAdded(player)
local bv = Instance.new("BoolValue")
bv.Parent = player
bv.Name = Frostbite
bv.Value = false
end



game.Players:PlayerAdded:connect(onPlayerAdded)

I hope this helped.

For more info on BoolValue go here: http://wiki.roblox.com/index.php/RBX.lua.BoolValue_(Object)

0
I found some minor flaws in your script. Around the name 'Frostbite', you're going to need some air quotes. Shawnyg 4330 — 10y
0
Oh yeah, thanks. Dominical 215 — 10y
0
Hmm, It works fine for randomizing. But it just cannot find the Sickness Model inside of the player. GingerBiscuit99 30 — 10y
0
Then do the same thing when a player joins. Just put the Sickness in there. Dominical 215 — 10y

Answer this question