I am trying to make it so there is a part that is cloned with a value inside of it. When the part is cloned, the value is set to a specific value.
In another script, (inside of a click detector inside of the part), there are the following values and events:
local val = script.Parent.Parent.Value
script.Parent.MouseClick:connect(function(val)
remoteEvent:FireAllClients(val)
end)
I need val to be updated when the part is cloned, so lets say in the part being cloned val is set to 5. When the part is cloned, the value is still set to 5, and hasn’t been updated. I know I can just put this in a while true do loop but I feel like that is unnecessary and there is a way to check if it has been cloned or not.
1 Like
What is the point of that RemoteEvent. 
for a UI, apparently you cant use clickdetector in localscripts, or atleast thats what I found from a quick google search, so instead Im just having a fireallclients event (its singleplayer, so it doesnt matter) to get to a localscript to do whatever it needs to to the UI. Or, is it possible to put UI on serverside?
Wrong, you can use ClickDetector.MouseClick in localscripts but localscripts can’t run if they are a descendant of workspace and not parented by a character model at the same time.
All localscripts for ui should either be placed in StarterGui or StarterPlayerScripts. Localscripts are used only for the players client, which means you should only use localscripts for messing with ui as it will have the fastest response to the localplayer.