Problems With image buttons in Roblox Severs

  1. Im trying to Get an image button working.
    2.only works in Roblox Studio but not in normal Roblox servers.
  2. Trying changing Code and looking for errors
    Code
    local Player = game.Players.LocalPlayer

local Clicks_Value_finder = Player.PlayerGui.Main_UI.Values_Folder.Clicks_Value
local Buttion = script.Parent
Buttion.MouseButton1Click:Connect(function()
wait(0.4)
Clicks_Value_finder.Value = Clicks_Value_finder.Value+Player.PlayerGui.Main_UI.Values_Folder.Click_Stats.Value
print(Clicks_Value_finder.Value)
end)

Can you post your code in lua coding?

Example

Ok sure
local Clicks_Value_finder = Player.PlayerGui.Main_UI.Values_Folder.Clicks_Value local Buttion = script.Parent Buttion.MouseButton1Click:Connect(function() wait(0.4) Clicks_Value_finder.Value = Clicks_Value_finder.Value+Player.PlayerGui.Main_UI.Values_Folder.Click_Stats.Value print(Clicks_Value_finder.Value) end)

Hmm, did you publish your studio :thinking:

“did you publish your studio” I did

Do it again and try again, I think that’s the problem.

Also, is the button the parent of the script? Or is it a child of the parent?

“Also, is the button the parent of the script? Or is it a child of the parent?” it’s yes

It may be that in a live server, things aren’t fully loaded and may fail instantly. I don’t think this happens in Studio, so that may be the issue. Check if using WaitForChild on these helps.

1 Like

It’s the parent of the script? If so, try this:

Edit: I fixed the script, try this, It should work.

    while wait() do if Player.PlayerGui["Main_UI"]["Values_Folder"]["Clicks_Value"] then break end end
    local ClicksValueFinder = Player.PlayerGui["Main_UI"]["Values_Folder"]["Clicks_Value"] 
    local Button = script.Parent
    Button.MouseButton1Click:Connect(function() 
    wait(0.4) 
    ClicksValueFinder .Value = ClicksValueFinder .Value + Player.PlayerGui["Main_UI"]["Values_Folder"]["Click_Stats"].Value 
    print(ClicksValueFinder) 
    end)

It doesn’t send an error? I think u need to add PlayerGui :WaitForChild(“Main_UI”)

That’s true, I edited mine to wait for Player.PlayerGui[“Main_UI”][“Values_Folder”][“Clicks_Value”]. I think it should work now.

Okay. If this works, please set the solution in here so we know it’s been solved.

“Okay. If this works, please set the solution in here so we know it’s been solved.” ok

I Got this error. Players.ZanderMander19.PlayerGui.Main_UI.Clicking_Buttion.Clicking_buttion_Script:3: attempt to index nil with 'PlayerGui'

1 Like

Here :

local Player = game.Players.LocalPlayer

local PlayerGui = Player:FindFirstChild("PlayerGui")

if PlayerGui then
	local MainGui = PlayerGui:FindFirstChild("Main_UI")
	if MainGui then
		local ClicksValueFinder = MainGui["Values_Folder"]["Clicks_Value"]
		local Button = script.Parent
		Button.MouseButton1Click:Connect(function()
			wait(0.4)
			ClicksValueFinder.Value = ClicksValueFinder.Value + MainGui["Values_Folder"]["Click_Stats"].Value
			print(ClicksValueFinder.Value)
		end)
	end
end
1 Like

no errors and doesn’t work. maybe else for player GUI like
if PlayerGui then local MainGui = PlayerGui:FindFirstChild("Main_UI") if MainGui then local ClicksValueFinder = MainGui["Values_Folder"]["Clicks_Value"] local Button = script.Parent Button.MouseButton1Click:Connect(function() wait(0.4) ClicksValueFinder.Value = ClicksValueFinder.Value + MainGui["Values_Folder"]["Click_Stats"].Value print(ClicksValueFinder.Value) end) else local ClicksValueFinder = MainGui["Values_Folder"]["Clicks_Value"] local Button = script.Parent Button.MouseButton1Click:Connect(function() wait(0.4) ClicksValueFinder.Value = ClicksValueFinder.Value + MainGui["Values_Folder"]["Click_Stats"].Value print(ClicksValueFinder.Value) end) end end

That error isn’t in the script I sent you.