I’m trying to create a script to detect when a player touches a part, then changes another parts properties such as Cancollide.
My script isnt working for some reason and, I’m trying to find somebody who understands why, I’ve tried to make a new script with no success.
Here is the script
local p = game.Workspace.Part
local door = game.Workspace.Part2
local function touch(Part)
local partParent = game
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
door.CanCollide = false
end
end
Your script also isn’t working cause you’re defining the partParent as game and not the parameter the Touched event gives you, why though?
Try this:
local p = game.Workspace.Part
local door = game.Workspace.Part2
local function touch(Part)
if Part.Parent:FindFirstChild("Humanoid") then
door.CanCollide = false
end
end
p.Touched:Connect(touch)
print("Script online")
local p = game.Workspace.Part
local door = game.Workspace.Part2
local function touch(Part)
print("Part touched")
if Part.Parent:FindFirstChild("Humanoid") then
print("Door colission changed")
door.CanCollide = false
end
end
p.Touched:Connect(touch)