Text not updating

  1. What do I want to achieve? So i want to update the text of a status label or tween a frame whenever a player clicks a button

  2. What is the issue? It is not updating the text even though no errors

  3. What solutions have I tried so far? Looked at yt vids, other forum posts and devhub but still cant find a solution

-- module script

local items = game.ReplicatedStorage.Shared:WaitForChild("Tools")
print("ok")
function remotecon.buy(player,toolName)
	print("workinh?")
	local tool = items:FindFirstChild(toolName)
	print("A")
	if tool ~= nil then
		print("Aa")
		if not player.Ownedtools:FindFirstChild(toolName) and player.Equipped.Value ~= toolName then
			local price = tool.Cost.Value
			print("aaaa")
			--plr dosent have tool
			if player.leaderstats.Coins.Value >= price  then
				print("sugoma")
				local newtoolval = Instance.new("StringValue")
				print("THIS IS SPONSERED")
				newtoolval.Name = toolName
				print("Ajh")
				newtoolval.Parent = player
				print("Ajjk")
				player.Equipped.Value = toolName
				print("Ad")
				
				for i,v in pairs(player.Backpack:GetChildren()) do
					print("A")
					if v:IsA("Tool") then
						print("Avf")
						v:Destroy()
						print("Aplx")
					end
					print("pid")
				end
				print("stu")
				local gear = tool:Clone()
				print("z")
				gear.Parent = player.Backpack
				local gear2 = tool:Clone()
				gear2.Parent = player.Ownedtools
				print("y")
				player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - price
				print("x")
				return "Yes"
		
			else 
				return "no"
			
			end
		elseif player.Ownedtools:FindFirstChild(toolName) and player.Equipped.Value ~= toolName then
			print("h")
			for i,v in pairs(player.Backpack:GetChildren()) do
				print("A")
				if v:IsA("Tool") then
					v:Destroy()
					print("m")
				end
			end

			local gear = tool:Clone()
			print("f")
			gear.Parent = player.Backpack
			print("c")
			
			return "Equipped"
		elseif player.Ownedtools:FindFirstChild(toolName) and player.Equipped.Value == toolName then
			print("b")
			for i,v in pairs(player.Backpack:GetChildren()) do
				print("raid")
				if v:IsA("Tool") then
					v:Destroy()
					print("shadow")
				end
			end

			local gear = tool:Clone()
			print("legends")
			gear.Parent = player.Backpack
			return "Equipped"
		end
		
	else
		return "error"
	end
end

--Server script
local remotecon = require(script.Parent.remotescript)

	local buytool = game.ReplicatedStorage.Remotes.buytool

buytool.OnServerInvoke = function(player, toolName)
	remotecon.buy(player,toolName)
end
--Client script

local RS = game:GetService("ReplicatedStorage")
local Shared = RS:WaitForChild("Shared")
local ToolFolder = Shared:WaitForChild("Tools")
local Tools = ToolFolder:GetChildren()
local parent = script.Parent
local selectedtemp = nil
local toolsGui = parent:WaitForChild("tools_gui")
local toolsFrame = toolsGui:WaitForChild("tools_frame")
local scrollingFrame = toolsFrame:WaitForChild("ScrollingFrame")
local temp = scrollingFrame:WaitForChild("temp")
local shop = script.Parent.tools_gui.tools_frame
local buy = shop:WaitForChild("canbuy")
local framess = toolsGui:WaitForChild("Frame")
local status = shop:WaitForChild("status")
for i, item in ipairs(Tools) do
	if item:IsA("Tool") then
		local price = item:FindFirstChild("Cost")
		local img = item:FindFirstChild("ImgID")
		local order = item:FindFirstChild("order")
		
		if price and img and order then
			print(item.Name)
			local temp = temp:Clone()
			temp.Parent = scrollingFrame
			temp.Name = item.Name
			temp.img.Image = img.Value
			local priceval = Instance.new("StringValue")
			priceval.Value = price.Value
			priceval.Parent = temp
			temp.Visible = true
			temp.MouseButton1Click:Connect(function()
				shop["tool_img"].Image = img.Value
				selectedtemp = temp
				shop.price.Text = price.Value
				shop.name.Text = item.Name
			end)
		else
			continue
		end
	end
end

if selectedtemp ~= nil then
	
end

shop.canbuy.MouseButton1Click:Connect(function()
	print(selectedtemp)
	if selectedtemp ~= nil then
		local result = game.ReplicatedStorage.Remotes.buytool:InvokeServer(selectedtemp.Name)
		print(result)
		if result == "Equipped"  then
			status.Text = "Equipped"
		
		elseif result == "Yes" then
			status.Text = "Equipped"
		
		elseif result == "No" then
			status.Text = "Buy"
			framess:TweenSize(UDim2.new(0.279, 0,0.1, 0) ,
				"Out" ,
				"Elastic" ,
				1
			)
		
		
		end
	print("Working")

	end
end)

2 Likes

Try capitalizing the N., so it’s

return "No"

instead.

still doesn’t work idk why and no errors in output tab

it still doesn’t work, i watched alot of videos yet cant find a solution.

does anything show in the output?? if something does, please show me it.

Maybe change the name of the “temp” in the loop on the client script. It seems to interfer with the temp varible above

nothing shows in the output lol.

both are the same, the variable was the clone of a button. and the button’s name is the object’s name

ok. try this above.

this might be causing your loop to break

yea i think that the names still have to be different. sometimes it might get the clone, other times it might get the template

oh ok but it still doesnt work, ay idea?

I am trying to figure it out right now. Add a print to the loop in the client and one in the server

Are you sure that there is nothing printing in the output

Wait a minute. Where is your local script located??

Hello.
I managed to get a local script working. Changed it alot compared to the one provided here. If you need any help just dm me or something

--Improved Client script

local RS = game:GetService("ReplicatedStorage")
local Shared = RS:WaitForChild("Shared")
local ToolFolder = Shared:WaitForChild("Tools")
local Tools = ToolFolder:GetChildren()
local selectedtemp = nil
local toolsGui = script.Parent
local toolsFrame = toolsGui:WaitForChild("tools_frame")
local scrollingFrame = toolsFrame:WaitForChild("ScrollingFrame")
local temp = script.temp
local shop = script.Parent.tools_frame
local buy = shop:WaitForChild("canbuy")
local framess = toolsGui:WaitForChild("Frame")
local status = shop:WaitForChild("status")

for i, item in ipairs(Tools) do
	if item:IsA("Tool") then
		local price = item:FindFirstChild("Cost")
		local img = item:FindFirstChild("ImgID")
		local order = item:FindFirstChild("order")

		if price and img and order then
			print(item.Name)
			local tempClone = temp:Clone()
			tempClone.Parent = scrollingFrame
			tempClone.Name = item.Name
			tempClone.Image = img.Value
			local priceval = Instance.new("StringValue")
			priceval.Value = price.Value
			priceval.Parent = tempClone
			tempClone.Visible = true
			tempClone.MouseButton1Click:Connect(function()
				shop["tool_img"].Image = img.Value
				selectedtemp = tempClone.Name
				shop.price.Text = price.Value
				shop.name.Text = item.Name
			end)
		else
			continue
		end
	end
end

buy.MouseButton1Click:Connect(function()
	print(selectedtemp)
	if selectedtemp ~= nil then
		local result = game.ReplicatedStorage.Remotes.buytool:InvokeServer(selectedtemp)
		print(result)
		if result == "Equipped"  then
			status.Text = "Equipped"

		elseif result == "Yes" then
			status.Text = "Equipped"

		elseif result == "No" then
			status.Text = "Buy"
			framess:TweenSize(UDim2.new(0.279, 0,0.1, 0) ,
				"Out" ,
				"Elastic" ,
				1
			)


		end
		print("Working")

	end
end)

Couldnt properly test the whole thing but here is a video of what i think is how you want this to work

1 Like

it is located in starterGui

I HATE THE LIMIT

1 Like

it doesn’t work, snd yes that is what i want.

yes, i am it prints nothing.

Limit moment

Ok then. Luckily i still have the file saved.
Check it out here.

Tools system.rbxl (55.5 KB)

Hope this somehow helps (Its just the client script*)

hey , after de-bugging my code a bit more (the original one) it says nil when i print the result. Any ideas why?

hey just found that out now as i was decoding it.
In the server script it doesnt return what the module returned


--Server script
local remotecon = require(script.ModuleScript) -- wherever the module script is

local buytool = game.ReplicatedStorage.Remotes.buytool -- wherever the remote event is

buytool.OnServerInvoke = function(player, toolName)
	local something = remotecon.buy(player,toolName)
	return something
end