script.Parent.Touched:connect(function(part) local s = script.Gui:clone() s.Parent = game.Players:FindFirstChild(part.Parent.Name).PlayerGui end)
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.
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