Script not working on client but works in server

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

Thats because ur mistaking client to server and how it works

I am not using remote events though.

If you vary and/or add objects and strings on the Server or Client, it won’t be read by the other.

do these exist inside the localscript

I don’t really get quite of your problem. The code seems fine, what are you trying to achieve?

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

It doesn’t work still same results.

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.

This should work hopefully

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)

Sorry but that doesn’t work either… I don’t know what’s wrong with it!

Do the levels even change? test print the values

Are you cloning “DarkMagicDragon” to the player’s character?

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!