What do you want to achieve? I want to make a part that displays How many times a part has been touched across all servers and update it constantly between servers, and also save the value, example
What is the issue? I just don’t know how to go about this, I am not that good at scripting and I don’t really know how to do global stuff.
What solutions have you tried so far? I have tried to make a Script in ServerScriptService that updates the part frequently, and every time you touch the part it changes the value inside the part.
The script:
local sign = workspace[“touch counter”]
while true do
sign.main.SurfaceGui.Textvalue.Text = “”…sign.Touches.Value
wait(50)
end
Like I said I am not the best at scripting and not good at the global stuff so if you can help me that would be great! Thanks for reading and have a nice day!
--script as a child of the part
local touches = --link the IntValue position
local debounce = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if debounce == false then
debounce = true
touches.Value = touches.Value + 1
wait(1)
debounce = false
end
end
end)
--script as a child of the sign
local touches = --link the IntValue position
local text = --link Text Label Position
touches.Changed:Connect(function()
--using a .Changed function does the same as while loop, but faster and causes less lag
text.Text = "This part has been touched "..touches.Value.." times."
end)
DataStoreService may help with storing the amount of times the part has been touched. You should save the value when the server stops, BindToClose will fire a function you gave when it happens.
I would suggest MessagingService for this type of system. That is meant for just this sort of thing. With messaging service you can PublishAsync() and :SubscribeAsync() when the part is touched using the Touched event
You typed sign.main.SurfaceGui.Textvalue.Text = “”…sign.Touches.Value thats not correct because you typed three dots you need to type just 2 here’s the script:
local sign = workspace[“touch counter”]
while true do
sign.main.SurfaceGui.Textvalue.Text = “” …sign.Touches.Value
wait(50)
end
Best way to go about this would probably be to use MessagingService along with DataStoring. I would save the value when the server closes, and communicate when the part is touched with MessagingService.