Text not updating on SurfaceGUI

I’m a rookie at scripting, and I’m trying to make it so that when the event is triggered, it adds 1 to the value and changes the text to the value, but for some reason, the text and value remain the same.

local triggerPart = script.Parent
local events = game.ReplicatedStorage.Events
local event = events.Smoked


triggerPart.Touched:Connect(function(hit)
    if hit.Parent.Name == "elg" or hit.Parent.Name == "elk" then
		event:FireAllClients("smoked")
		hit:Destroy()
		print("smoked meat")
	end
end)

and

local events = game.ReplicatedStorage.Events
local event = events.Smoked
local value = script.Parent.count
local text = script.Parent.Count

event.OnClientEvent:Connect(function(action)
	if action == "smoked" then
		value.Value = value.Value + 1
		text.Text = tostring(value.Value)
	end
end)

overall your script looks fine, perhaps provide a screenshot of your output post playtest and we’ll figure out things if errors are present.

1 Like

Put a print function into the if statement to see if its actually activating or not. Also where is the local script located

I looks like you have two things named count, one starts with a capital letter on the local script, but it’s probably unintentional

Putting a print function into the if function gave no result, however the print function in the other script works fine.

LocalScripts, with the exception of being inside of a player’s character, cannot run in Workspace. Your SurfaceGui must be moved to StarterGui, and its Adornee set to Counter.Count to continue rendering as it was before

You can put a normal script and change it’s run context property to client if you want a working local script in workspace btw

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