My upgrade script isnt working

nothing i do can make either script work
i changed the script that changes the text to

game.Players.PlayerAdded:Connect(function(plr)
	local player = plr
	local ufolder = player.ufolder
	scprice = ufolder.scprice
end)

script.Parent.Text = scprice.Value

scprice:GetPropertyChangedSignal("Value"):Connect(function()
	script.Parent.Text = scprice.Value
end)

but im getting this error

ive also added prints to both button scripts and came to the conclusion that the button just isnt pressing, this first print statement isnt printing

script.Parent.MouseButton1Click:Connect(function()
	print("button presses")
	if points.Value >= scprice.Value then
		event:FireServer()
		print("fired server")
	end
end)

so idk what to do

im sorry to be constantly bothering you with this ongoing issue but idk else what do to

Well, firstly, I thought that this problem was in the StarterGui, but as I see it, your gui is in the workspace, and the script simply won’t work. Move it to the StarterGui, and bind the text you want to change, or StarterPlayer > StarterCharacterScripts

Or you can upload the full map here, and then I’ll tell you exactly how to do it.

its not a local script so it can run in the workspace

Yes, it may work, but it won’t update. And also displayed for all players, that is, after someone else enters, the text will change.

game file.rbxl (60.2 KB)

Now I’ll take a look. And I’ll tell you what the problem is.

1 Like

Well, in general, I found the problem, and solved it.

Без имени
You need to drop the script into StarterGui and change it to this one.

local plr = game.Players.LocalPlayer
local Event = script.UpdateEvent
local Button = game:GetService("Workspace"):WaitForChild("upgrader"):WaitForChild("spawncap"):WaitForChild("SurfaceGui"):WaitForChild("Frame"):WaitForChild("Frame"):WaitForChild("button")
--stats--
local statfolder = plr:WaitForChild("statfolder")
local ufolder = plr:WaitForChild("ufolder")
local points = statfolder:WaitForChild("points")
local spawncap = statfolder:WaitForChild("spawncap")
local scprice = ufolder:WaitForChild("scprice")

Button.MouseButton1Click:Connect(function()
	print("button presses")
	if points.Value >= scprice.Value then
		Event:FireServer()
		print("fired server")
	end
end)

And everything will work.

alr i see how that would fix it, im trying it now

thanks for all your help, it works perfectly now

one last thing

game.Players.PlayerAdded:Connect(function(plr)
	local player = plr
	local ufolder = player.ufolder
	scprice = ufolder.scprice
end)

script.Parent.Text = scprice.Value

scprice:GetPropertyChangedSignal("Value"):Connect(function()
	script.Parent.Text = scprice.Value
end)

im getting this error

Just replace the same script with this one:

local plr = game.Players.LocalPlayer
local Event = script.UpdateEvent
local Button = game:GetService("Workspace"):WaitForChild("upgrader"):WaitForChild("spawncap"):WaitForChild("SurfaceGui"):WaitForChild("Frame"):WaitForChild("Frame"):WaitForChild("button")
local TextLable = game:GetService("Workspace"):WaitForChild("upgrader"):WaitForChild("spawncap"):WaitForChild("SurfaceGui"):WaitForChild("Frame"):WaitForChild("Frame"):WaitForChild("price")
--stats--
local statfolder = plr:WaitForChild("statfolder")
local ufolder = plr:WaitForChild("ufolder")
local points = statfolder:WaitForChild("points")
local spawncap = statfolder:WaitForChild("spawncap")
local scprice = ufolder:WaitForChild("scprice")
TextLable.Text = scprice.Value

Button.MouseButton1Click:Connect(function()
	print("button presses")
	if points.Value >= scprice.Value then
		Event:FireServer()
		print("fired server")
	end
end)
scprice:GetPropertyChangedSignal("Value"):Connect(function()
	TextLable.Text = scprice.Value
end)

This should help.

1 Like

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