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

This ontouch script isn't working cancollide won't change?

Asked by 8 years ago
Edited 8 years ago
script.Parent.Touched:connect(function(hit)
    game.Workspace.Blocker1.CanCollide = true
end)

really easy right? but the block's cancollide does not work it doesn't allow it to be collided with

CanCollide is already false i want it to be true though

4 answers

Log in to vote
0
Answered by 8 years ago
script.Parent.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        game.Workspace.Blocker1.CanCollide = true
    end
end)

Its good to use FindFirstChild because script.Parent can be touched by anything and that can really mess things up!

Ad
Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

You're setting CanCollide to Truewhen you're supposed to make it False.

script.Parent.Touched:connect(function()
    game.Workspace.Blocker1.CanCollide = false
end)
0
but when it's false you can't touch it i want you to be able to touch it arrowman888 69 — 8y
Log in to vote
0
Answered by 8 years ago

True is the default value of Cancollide. If you want to go through it, then you want to set it to false.

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

This might help:

local Blocker = workspace:WaitForChild("Blocker1")

Blocker.Touched:Connect(function(Touch) -- If the part is touched, it will connect a function to it.
    local Humanoid = Touch.Parent:FindFirstChild("Humanoid") -- This looks for a humanoid.
    if Humanoid ~= nil then - If there is a humanoid, do this:
        local Player = game.Players:GetPlayerFromCharacter(Humanoid.Parent) -- Looks for a player
        if Player ~= nil then -- If a player is found, it will set the parts' CanCollide property to false.
            Blocker.CanCollide = false
        end
    end
end)

Answer this question