ive tryed this
part = game.Workspace.Part
if part.Touched then
part:Destroy()
end
But it dissapears before my player touches it, i even lifted and anchored it in the air and it still does the same.
ive tryed this
part = game.Workspace.Part
if part.Touched then
part:Destroy()
end
But it dissapears before my player touches it, i even lifted and anchored it in the air and it still does the same.
Very easy question. First off, I would personally put the script to be parented by the part (unless the script is part of a bigger script). Second off, make sure this is a default script and not a local script or module script. You can find them all somewhere in the topbar of Studio.
If you put it in a script parented by the part, it would look something like this:
local part = script.Parent
function onContact(brick)
local humanoid = brick.Parent:findFirstChild("Humanoid")
If hum and hum ~= nil then
local char = hum.Parent
local player = game.Players:GetPlayerFromCharacter(char)
If char and player then
part:Destroy()
end
end
end
part.Touched:connect(onContact)
I hope this helped. :)
PS: I wrote this on my phone so sorry for the sloppiness of it. PPS: Sorry for all the edits but my phone liked to "correct" a lot of it, lol.
This discussion is preserved as it was. New answers, comments, and votes are closed.