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

Why doesn't this work whenever the part touiches another part? [Unanswered]

Asked by
Prioxis 673 Moderation Voter
9 years ago

So I have this part that is created with this script

local Player = game.Players.localPlayer
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)

and whenever the part touches another part I want it this script (located in the part created above) to fire its function

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

for some reason it doesn't work and its not the collision either

3
1) Why is your event in a loop? 2)Why are you referencing localplayer(incorrectly)? It should be a normal script 3) Leave the script enabled. It won't run in Lighting. NotsoPenguin 705 — 9y
0
"Why are you referencing localplayer(incorrectly)?" I think that should be a statement rather than a question lol DigitalVeer 1473 — 9y
0
the 2nd script has the error.... the first script is just the understanding of how the 2nd script works Prioxis 673 — 9y
0
Overall your code just doesn't make any sense. What are you trying to accomplish here? Goulstem 8144 — 9y
0
It makes perfect since if the part created in the first script touches another part check the touched part for a Object c alled ItemName if that object exists then print the objects parent's name Prioxis 673 — 9y

1 answer

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

First off, remove the local player line, and move the first script into a normal script, and move it to server script service,

Then remove the while wait loop, it's useless, and inefficient.

Finally, make sure ItemName is actually a child of the correct part, and that it's capitalization is correct.

Ad

Answer this question