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 made a script and parented it to workspace this script is "main" It clones the Model of BoolValues into the player, and it gives the player leaderstats. I also have a SickScript for these BoolValues, Each BoolValue has a different impact on the player. The SickScript is 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: 14:38:17.918 - Sickness is not a valid member of Player 14:38:17.921 - Script 'Workspace.Sick', Line 7 14:38:17.925 - stack end
The Sickness Model is cloned into the player via the PlayerAdded event.
It may be running before the value is cloned, try adding in a if statement to see if sickness exists within the player before trying to run code with it.
WaitForChild() method is perfect for this case:
local sickness = player:WaitForChild("Frostbite")
This will wait until
Frostbite exists on the player and then put
Frostbite into the local
sickness variable where you can then access it.