01 | script.Parent.Touched:Connect( function (hit) |
02 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
03 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
04 | local descendants = player.Character:GetDescendants() |
05 | if player ~ = nil then |
06 | for index, descendant in pairs (descendants) do |
07 | if descendant:IsA( "BasePart" ) and ( "Decal" ) and descendant ~ = player.Character.HumanoidRootPart then |
08 | descendant.Transparency = 1 |
09 | end |
10 | end |
11 | local scriptt = game.ReplicatedStorage.Scrapt:Clone() |
12 | scriptt.Parent = player.Character |
13 | wait( 11 ) |
14 | scriptt:Destroy() |
15 | for index, descendant in pairs (descendants) do |
so basically when i hit a part i want it to copy a script but it copys it alot of times and ruining the actual mecanique so idk wat to do
You need a debounce. The character keeps touching the part over and over again, so you need to keep that from happening, there are a couple ways to go about this.
One touch This method will only allow the first person to touch it, then not anybody else.
The script beginning should look like this:
1 | debounce = true |
2 |
3 | script.Parent.Touched:Connect( function (hit) |
4 | if hit.Parent:FindFirstChild( "Humanoid" ) and debounce = = true then |
5 | debounce = false |
Touch then wait This method will allow somebody to touch it, then after x seconds they can touch it again.
1 | debounce = true |
2 |
3 | script.Parent.Touched:Connect( function (hit) |
4 | if hit.Parent:FindFirstChild( "Humanoid" ) and debounce = = true then |
5 | debounce = false |
6 | --All the code goes here |
7 | wait( 5 ) |
8 | debounce = true |
9 | --All the ends |
Hope this helped!