Script doesnt works

i made script that will increase Ysize of part every time until Ysize goes 73. but it doesnt works, how to fix that?

local water = workspace.map.WATER


    if game.StarterGui.time.meow.Value == 2 then

repeat
			wait(0.1)
			water.Size = Vector3.new(water.Size.X, water.Size.Y + 0.5, water.Size.Z)
			
		until
	water.Size==Vector3.new(water.Size.X, 73.5,water.Size.Z)
	end
1 Like

are you getting an error? Is the part growing and doesn’t stop growing?

Try this code out:

local water = script.Parent

if game.StarterGui.time.meow.Value == 2 then
	repeat
		task.wait(.1)
		water.Size = Vector3.new(water.Size.X, water.Size.Y + 0.5, water.Size.Z)
	until water.Size.Y == 73.5
end

theres no error, part just not changing size

1 Like

If the code I gave you doesn’t work, try printing the value.

game.StarterGui.time.meow.Value

Check if meow even exists, if so, then check if the value is not 2.

What kind of script is it? Local script? Or normal? Where did you put it?

i put that in part as a normal script

yes, it printing 2 value. but still doesnt working

game.StarterGui doesn’t work. It’s not the right way. You need to access it client-sided.

still size not changing. maybe i need to try some other loop script?

Try using .Touched event and use

local part = script.Parent

part.Touched:Connect(function(hit)
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) 
 if player.PlayerGui.time.meow.Value == 2 then
         -- rest of the code here -- 
end
end)

Or try using Remote Event. If you know how this works.

I have just tested this code, it actually works perfectly fine. It increases the height of the part and stops when it reaches 73.5 studs (on the Y axis).

hmm, maybe theres something that i did wrong, thank you all! ill try to find some problems

OH, i think i got it. maybe its not working because i changing value after 20 seconds. can i do kinda wait for value to change?

1 Like

Are you sure the script isn’t disabled? What kind of script are you using (local or server script)? Where is the script located? Have you tried switching the current part for “water” to a different part?

You didn’t even explain when you want it to change also you shouldn’t access StarterGui but instead PlayerGui. From what I’ve read people pretty much already solved your issue. It’s just that you either didn’t even try to implement any of these or don’t know how to.

server script. its parented to that part
and yes, i tried

Isn’t this working? Did you even try it out?

I did, although it may have some mistakes

Try this out:

local PS = game:GetService("Players")

local water = script.Parent

water.Touched:Connect(function(toucher: BasePart)
	local model: Model = toucher:FindFirstAncestorWhichIsA("Model")
	local player: Player = PS:GetPlayerFromCharacter(model)
	
	if player then
		local meow = player.PlayerGui.time.meow
		
		warn(meow.Value)
		if meow and meow.Value == 2 then
			repeat
				warn("moving!")
				task.wait(.1)
				water.Size = Vector3.new(water.Size.X, water.Size.Y + 0.5, water.Size.Z)
			until water.Size.Y == 73.5
			warn("ended moving")
		end
	end
end)
1 Like