Why is the value of coins not showing up on my TextLabel?


Nothing in output

3 Likes

Can you select all script and paste instead of screenshot? THis would help me more

if you’re looking for something in the “output”, you need to print the value after assigning it.

local Part = game.Workspace.Part
local PartValue = Part.Value.Value

game.Players.PlayerAdded:Connect(function(joining)

local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = joining

local Coins = Instance.new("IntValue")
Coins.Name = "Coins"
Coins.Value = 3000
Coins.Parent =  leaderstats


PartValue = 200


local Part1 = game.Workspace.Part1
Part.Touched:Connect(function(touched)
	local humanoid = touched.Parent:FindFirstChild("Humanoid")
	if humanoid and PartValue == 200 then
		Part:Destroy()
		Part1.Transparency = 0
		
		local TotalScore = Coins.Value - PartValue
		print(TotalScore)
		Coins.Value = TotalScore
	end
	
	local CollecterCashButton = workspace.Collector
	local CashValueScreen = workspace.Collector.CashValueScreen
	
	CashValueScreen.SurfaceGui.TextLabel.Text = Coins.Value

end)
end)

Ahhh, In the

Part.Touched:Connect(function(touched)

You didn’t set a variable for Part

Edited : Nvm

local Part = game.Workspace.Part
local PartValue = Part.Value.Value

game.Players.PlayerAdded:Connect(function(joining)

local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = joining

local Coins = Instance.new("IntValue")
Coins.Name = "Coins"
Coins.Value = 3000
Coins.Parent =  leaderstats


PartValue = 200


local Part1 = game.Workspace.Part1
Part.Touched:Connect(function(touched)
	local humanoid = touched.Parent:FindFirstChild("Humanoid")
	if humanoid and PartValue == 200 then
		Part:Destroy()
		Part1.Transparency = 0
		
		local TotalScore = Coins.Value - PartValue
		print(TotalScore)
		Coins.Value = TotalScore
	end
	
	local CollecterCashButton = workspace.Collector
	local CashValueScreen = workspace.Collector.CashValueScreen
	
	CashValueScreen.SurfaceGui.TextLabel.Text = Coins.Value

end)
end)
wait this sory

its to do with the highlighted area thats not working

Here is the remaked script

local Part = game.Workspace.Part
local PartValue = Part.Value.Value

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local Coins = Instance.new("IntValue")
	Coins.Name = "Coins"
	Coins.Value = 3000
	Coins.Parent =  leaderstats
		
	local Part1 = game.Workspace.Part1
	Part.Touched:Connect(function(object)
		if object.Parent == player.Character then
			Part:Destroy()
			Part1.Transparency = 0

			Coins.Value =- 200
		end

		local CollecterCashButton = workspace.Collector
		local CashValueScreen = CollecterCashButton.CashValueScreen

		CashValueScreen.SurfaceGui.TextLabel.Text = Coins.Value
	end)
end)

Don’t forgot to like :heart: me and Solution :white_check_mark: me if it works!

2 Likes

yay thanks os much for helping!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.