Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Local Script Creating Values Help?

So I need a bunch of values from this local script I made. It 'Instance.news' all of them, and when I check the player, it works fine and it has all of the values.

The problem is, if the player dies, then they clone, making 2 pairs of each value, and it goes on

Is there any way to stop this from happening? I only want 1 of each value

This is the script:

player = script.Parent.Parent

local Heavy = Instance.new("BoolValue",player)
Heavy.Name = "Heavy"

local Scout = Instance.new("BoolValue",player)
Scout.Name = "Scout"

local Medic = Instance.new("BoolValue",player)
Medic.Name = "Medic"

local Builder = Instance.new("BoolValue",player)
Builder.Name = "Builder"

local Speed = Instance.new("NumberValue",player)
Speed.Name = "Speed"

local Health = Instance.new("NumberValue",player)
Health.Name = "Health"

1 answer

Tested and everything. Works just as described. Hints in the script explain how it is done.

Make sure that this is in a LocalScript in StarterGui

--Scripted by EncryptX [11-30-14]
local player = script.Parent.Parent
local item1;
if not player:findFirstChild("Heavy") then --Check for already existing item
local Heavy = Instance.new("BoolValue",player)
Heavy.Name = "Heavy"
else
item1 = player.Heavy
end

local item2;
if not player:findFirstChild("Scout") then
local Heavy = Instance.new("BoolValue",player)
Heavy.Name = "Scout"
else
item2 = player.Scout
end

local item3;
if not player:findFirstChild("Medic") then
local Heavy = Instance.new("BoolValue",player)
Heavy.Name = "Medic"
else
item3 = player.Medic
end

local item4;
if not player:findFirstChild("Builder") then
local Heavy = Instance.new("BoolValue",player)
Heavy.Name = "Builder"
else
item4 = player.Builder
end

local item5;
if not player:findFirstChild("Speed") then
local Heavy = Instance.new("BoolValue",player)
Heavy.Name = "Speed"
else
item5 = player.Speed
end

local item6;
if not player:findFirstChild("Health") then
local Heavy = Instance.new("BoolValue",player)
Heavy.Name = "Health"
else
item6 = player.Health
end

1 comment

0

Sorry but I don't have this question anymore. Plus you messed up some parts like health and speed are numbervalues and stuff, but thanks for trying

This discussion is preserved as it was. New answers, comments, and votes are closed.