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

Clone script won't work. Why?

Asked by 9 years ago
script.Parent.Touched:connect(function(part)
local s = script.Gui:clone()
s.Parent = game.Players:FindFirstChild(part.Parent.Name).PlayerGui
end)
0
Any errors? GoldenPhysics 474 — 9y
0
Nothing. No errors. I'll check if there is any output. EzraNehemiah_TF2 3552 — 9y
0
it says, "Disconnected event because of exception". EzraNehemiah_TF2 3552 — 9y

3 answers

Log in to vote
-1
Answered by 9 years ago

Make sure the humanoid is nil.

Ad
Log in to vote
1
Answered by
ipiano 120
9 years ago

I'm guessing what's happening is that something else is hitting the part than a person. If a random flying object hits it, It'll fire, and attempt to find a player called "Part" or whatever the thing that hit it is called. Try putting this inside the function instead.

if part.Parent:FindFirstChild("Humanoid") ~= nil then
    local s = script.Gui:clone()
    s.Parent = game.Players:FindFirstChild(part.Parent.Name).PlayerGui
end

That'll ensure that whatever hit the part is a person and not some random brick.

Of course, if the part being hit is in an enclosed environment where nothing else can hit it, then I'm completely wrong.

0
Oh... DERP. Thanks... Should of thought of that... EzraNehemiah_TF2 3552 — 9y
Log in to vote
0
Answered by 9 years ago

Try to make sure it is actually a robloxian you are dealing with.

To make sure you are dealing with a humanoid , you will need this:

local h = part.Parent:FindFirstChild("Humanoid")
if h ~= nil then

It is saying if the humanoid exists, then it will clone the GUI.

Make sure to add an end for the if+then

Add this with it: (Don't forget to create the function)

local h = part.Parent:FindFirstChild("Humanoid")
if h ~= nil then

local s = script.Gui:clone()
    s.Parent = game.Players:FindFirstChild(part.Parent.Name).PlayerGui
end
0
Someone already answered it. Thanks anyway. EzraNehemiah_TF2 3552 — 9y

Answer this question