How to adjust the script to work in other function

Hello develupers this Is a sinple question look this script


It makes that when a player touches in your parent it gives a victory to the global leboard.
I want to tweak the script so the player gets a win if my boolValue is = true. And not by touching in this part. I puted the script in severScriptService and make a boolValue in replicated storage but With my method of using if boolValue.Value == true them …
Didn’t worked then you can help? Thank you
Sorry I can’t put scripts in here beacause I’m making a post on my cell phone.

there is hit:FindFirstChild(“Humanoid”) try
hit.Parent:FindFirstChild(“Humanoid”) instead

No not is it I want to make the player get the win if the Value is == true and not by touching in our parent

when u have if debounce == false add and game.ReplicatedStorage.boolValue.Value == true

is this what u wanted? sorry if i dont understand

what is your boolvalues name and parent?

Look The script makes that if you touches in parent of the script the player get a win I want to make the same thing happens but if the Value == true and not by touching in script. parent

do u mean that at the moment the value changes THEN someone gets the win?

Yes and not by touching in a part I want to the player get if value is == true

ok but who is the player that gets the win?

I Want when the value is set to true all players in the sever get a win

ohhh finally u told the whole thing. just a minute i write the script

Sorry I didn’t explain it very well in the post

what is your boolvalue name? is it boolValue or what

Okay the name is “WinValue” and it is a bool value

Let me know if it works or errors

local datastore = game:GetService("DataStoreService"):GetOrderedDataStore("Wins")

game.ReplicatedStorage.WinValue.Changed:Connect(function()
	if game.ReplicatedStorage.WinValue.Value == true then
		for i,plr in ipairs(game.Players:GetChildren()) do
			datastore:IncrementAsync(plr.UserId,1)
		end
	end
end)
1 Like

Okay I will test and if work I will back :+1:

1 Like

Worked perfectly. Thank for your help😉

1 Like

No problem. have fun making your game!

Same for you if you need help I will help you