Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Distributing stuff wont work?

Asked by 10 years ago
script.Parent.Touched:connect(function(part)
if part.Parent:FindFirstChild("Humanoid") ~= nil then
script.LocalScriptz:clone().Parent = game.Players:FindFirstChild(part.Parent.Name).PlayerGui
end
end)

It copies more than and lags the game. I know it's stupid and I can figure it out... But still... Help!

1 answer

Log in to vote
0
Answered by 10 years ago

:clone()

Use :Clone() instead, also its because you are not debouncing.

You need to make a variable called debounce at the very top of the script Make it false Then, Make an if statement, that only carries on if it's false After that, redefine it true. It should look like this:

debounce = false
script.Parent.Touched:connect(function(part)
if debounce == false then
debounce = true
if part.Parent:FindFirstChild("Humanoid") ~= nil then
local cloned = script.LocalScriptz:Clone()
cloned.Parent = Game.Players:FindFirstChild(part.Parent.Name).PlayerGui
end
end
end)

Ad

Answer this question