So I have this part, do when another part touches it, it will weld to it, but if a player touches it it won’t weld. I am having trouble achieving this effect, every time the character would touch it, they would be welded to the part. Here is my code:
function touch(part)
if part:IsA ("BasePart") and part.Name ~= "#Weight" and part.Name ~= "Baseplate" and part.Parent:FindFirstChild("Humanoid") == nil then
local IsHuaman = part.Parent:FindFirstChild("Humanoid")
warn(IsHuaman)
if IsHuaman == nil then
local w = Instance.new("Weld")
w.Part0,w.Part1 = script.Parent.Platform,part
w.C0 = part.CFrame:toObjectSpace(script.Parent.Platform.CFrame):Inverse()
w.Parent = script.Parent.Platform
end
end
end
function UnWeld()
print("Unwelding...")
for i, v in pairs(Platform:GetChildren()) do
if v.ClassName == "Weld" then
if v.Part0 == Platform then
v:Destroy()
end
end
end
end
Platform.Touched:Connect(touch)
UnWeldEvent.OnServerEvent:Connect(UnWeld)