What do you want to achieve?
A way to stop anyone from teleporting while CanCollide is turned off
I’ve tried making a system that checks if the player is touching it while CanCollide is turned off
Here it is:
if game.Workspace.NoAnime.Touched while
game.Workspace.NoAnime.CanCollide == false then
h.parent.HumanoidRootPart.CFrame = CFrame.new(workspace["NoAnime"].Position)
end
This however, turned up with several errors. No clue where to go from here. Please help me!
Also, here’s the script above it:
script.Parent.Touched:Connect(function(h)
local hum = h.Parent:FindFirstChild("Humanoid")
if hum ~= nil then
h.parent.HumanoidRootPart.CFrame = CFrame.new(workspace["NoAnime2"].Position)
end
end)
while TouchedIt == true and game.Workspace.NoAnime.CanCollide == false do
h.parent.HumanoidRootPart.CFrame = CFrame.new(workspace[“NoAnime”].Position)
end
Maybe this would work? I’m on mobile sorry for messy answer. The bold code was the lines that I added that could work
There is a touch property that can be turned on and off in nearly every physical part’s properties. This mean that no .Touched events can occur from that part while that property is disabled.
Hi, I will be answering your question. Try this script.
script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local char = workspace[player.Name]
local waittime = 5 -- insert a time that will be used to change the debounce
local debounce = false
local parttoteleportto = game.Workspace.TestPart -- insert the part that you want the player to teleport to.
local success,err = pcall(function()
if debounce == false then
char:MoveTo(parttoteleportto.Position)
end
end)
if successs then
debounce = true
wait(timetowait)
debounce = false
end
end)
I went to sleep. Anyways, this didn’t work. It stopped me from teleporting but when collisions were turned on from another script, I wasn’t able to teleport.