I am making a dragon level system that if a dragon is a certain level, it makes the baby dragon parts and makes them transparent bringing the new dragon. The thing is I want to do this on the client so that others don’t have their dragon at a certain level as a different player’s dragon.
Script:
local Exp = script.Parent.Exp
local BabyDragon = script.Parent.Parent.BabyDragon
local TeenDragon = script.Parent.Parent.TeenDragon
local function setTrans(Target,Trans)
for i, v in pairs(Target:GetChildren()) do
if v.Name ~= "Eye" then
v.Transparency = Trans
end
end
end
while wait() do
if Level.Value > 30 then
Level.Value = 30
elseif Level.Value < 1 then
Level.Value = 1
end
if Level.Value <= 10 then
setTrans(BabyDragon,0)
setTrans(TeenDragon,1)
TeenDragon.Eye.Decal.Transparency = 1
TeenDragon.Eye2.Decal.Transparency = 1
elseif Level.Value >= 20 then
setTrans(BabyDragon,1)
setTrans(TeenDragon,0)
elseif Level.Value >= 30 then
print("Max Leveled")
end
end
You need to add a spawn function otherwise it will loop forever.
local Exp = script.Parent.Exp
local BabyDragon = script.Parent.Parent.BabyDragon
local TeenDragon = script.Parent.Parent.TeenDragon
local function setTrans(Target,Trans)
for i, v in pairs(Target:GetChildren()) do
if v.Name ~= "Eye" then
v.Transparency = Trans
end
end
end
spawn(function()
while wait() do
if Level.Value > 30 then
Level.Value = 30
elseif Level.Value < 1 then
Level.Value = 1
end
end)
if Level.Value <= 10 then
setTrans(BabyDragon,0)
setTrans(TeenDragon,1)
TeenDragon.Eye.Decal.Transparency = 1
TeenDragon.Eye2.Decal.Transparency = 1
elseif Level.Value >= 20 then
setTrans(BabyDragon,1)
setTrans(TeenDragon,0)
elseif Level.Value >= 30 then
print("Max Leveled")
end
end
if a pet is at a certain level, I want it to upgrade the looks by looping threw both models and changing their transparency. It works if I do it on a normal script but if I do it on a local script it doesn’t work.
local Exp = script.Parent.Exp
local BabyDragon = script.Parent.Parent.BabyDragon
local TeenDragon = script.Parent.Parent.TeenDragon
local function setTrans(Target,Trans)
for i, v in pairs(Target:GetChildren()) do
if v.Name ~= "Eye" then
v.Transparency = Trans
end
end
end
local function testCheck()
while wait() do
if Level.Value > 30 then
Level.Value = 30
elseif Level.Value < 1 then
Level.Value = 1
end
if Level.Value <= 10 then
setTrans(BabyDragon,0)
setTrans(TeenDragon,1)
TeenDragon.Eye.Decal.Transparency = 1
TeenDragon.Eye2.Decal.Transparency = 1
elseif Level.Value >= 20 then
setTrans(BabyDragon,1)
setTrans(TeenDragon,0)
elseif Level.Value >= 30 then
print("Max Leveled")
end
end
end
spawn(testCheck)
Yeah I am cloning it the dragon does level up. it works on a server script but not a local script. I don’t want everyone to have there dragons at a the same level and stuff.
I just found that if I put it in startercharacterscripts it works! But since the parent will be changing alot its going to break the script… what should I do!