so i made a text button on a part and when its clicked its supposed to grow a plant on a dirt but when clicked nothing happens, im not getting any errors tho. any help appreciated

local button = script.Parent
local dirt = game.Workspace.Tycoon.BioGarden.CropPole1.ZIEMIA
local plr = game.Players:WaitForChild(game.Workspace:WaitForChild("PlayerName").Value)
button.MouseButton1Click:Connect(function()
	if button.Parent.Empty.Value == true then
		button.Parent.Level.Value = 1
		local lvl1 = game.ServerStorage.Plants:FindFirstChild(button.Parent.SelectedSeed.Value.."1"):Clone()
		lvl1.Parent = dirt
		lvl1:MoveTo(dirt.Parent.Hitbox.Position)
		while true do
			wait(math.random(2,5)*plr.PlantSpeed.Value)
			if button.Parent.Level.Value >= button.Parent.MaxLevel.Value then
				dirt:ClearAllChildren()
				button.Parent.Level.Value = button.Parent.Level.Value + 1
				local clone = game.ServerStorage.Plants:FindFirstChild(button.Parent.SelectedSeed.Value..button.Parent.Level.Value)
				clone.Parent = dirt
				clone:MoveTo(dirt.Parent.Hitbox)
			end
		end
	end
end)

3 comments

0

You cannot just put a localscript. You would need to use RemoteEvents in this situation

0

its a normal script

0

Then change it to LocalScript.