How to change UI value by touching a part

Hey, I am currently trying to make a part that when touched would subtract a value from the UI folder, however all the ways I tried to keep failing, so how would I do this?

If you are changing the value in the UI from both the client and the server you will need to be using a remote event but without seeing your code I cant offer any definite fix

1 Like

Which part of the code do you need to see?

Whatever part of it isn’t working, mainly the part where your changing the value in the UI

1 Like

Well right now am trying to fire the remote event from the part but Its not working,here is the code:

local SELL = game.ReplicatedStorage.SELL

script.Parent.Touched:Connect(function()
SELL:FireClient()
print(“TOUCHED”)
end)

Your not defining the client that you want to fire in this script, that’s why its not working

script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then -- checking if the hit part was a player
local plr = game.Players:GetPlayerFromCharacter(hit.Parent) -- defining the player whos client I want to fire
SELL:FireClient(plr)-- firing the client that hit the part
print(“TOUCHED”)
end
end)
1 Like

Thanks a lot it worked! Ive been trying to fix that for hours, thanks :smile:

1 Like