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

Why doesn't the parts name get printed when another part touches it?

Asked by
Prioxis 673 Moderation Voter
9 years ago

So I have 2 scripts one that creates a part when the player joins and .1 the part moves to the players torso and its big enough that it engulfs the player ( the part is transparent)

THE ERROR IS IN SCRIPT 2 NOT 1

-- THERE IS NO ERROR IN THIS SCRIPT
game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:wait()
    plr.Character:WaitForChild("Torso")
    local torso = plr.Character.Torso
    local part = Instance.new("Part", game.Workspace)
    part.Transparency = 1
    part.CanCollide = false
    part.Size = Vector3.new(7,7,7)
    game.Lighting.Find:Clone().Parent = part
    part:FindFirstChild("Find").Disabled = false
    part.Anchored = true
while wait(0.025) do
    part.CFrame = CFrame.new(torso.Position)

end
end)
-- THERE IS NO ERROR IN THIS SCRIPT

and in that part a script is copied from the lighting to it I want that script that if the part touches anything to look for an object inside it called "ItemName" if that object exists then print the parents name

while wait(0.1) do
script.Parent.Touched:connect(function(hit)
    local found = hit:FindFirstChild("ItemName")
        if found then
            print(found.Parent.Name)
    end
end)
end

I don't see any errors in my code for the second script but for some reason it just doesn't work

0
Is the second script, which is originated from lighting, disabled? Goulstem 8144 — 9y

1 answer

Log in to vote
0
Answered by
ZeroBits 142
9 years ago

Remove the while wait(0.1) loop.

Make sure capitalization for ItemName is correct, and. That ItemName is a child of the colliding part, if another part from the same model impacts the brick it won't work.

There doesn't appear to be any other problems.

0
Lol thank you I don't know why I had the loop funny thing is that wasn't even the problem the parts were anchored and it caused the script to not work lol Prioxis 673 — 9y
0
huh, the part being anchored shouldn't have caused any problems, but the part being Non Collidable might. ZeroBits 142 — 9y
Ad

Answer this question