local part = script.Parent
part.Touched:Connect(function(hit)
local character = hit.Parent
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
if humanoidRootPart then
local newCframe = game.Workspace.Areas.Area.CFrame
humanoidRootPart.CFrame = newCframe
end
end)
I don’t the code needs to be this complicated but I am new to scripting so I don’t exactly know, thank you!
local part = script.Parent
part.Touched:Connect(function(hit)
local character = hit.Parent
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
print("cool")
if humanoidRootPart then
local targetCFrame = game.Workspace.Areas.Area.CFrame
humanoidRootPart.CFrame = targetCFrame
print("wow")
end
end)
Make sure the property CanTouch Is set to true. So the part can detect if something touched the part. And also make sure the part you are touching is the one you are defining in your script
Is the script enabled? Did u get any errors. Try putting a print statement where you are defining the part and also put one on the start of the function before the variables.
local part = script.Parent
local inuse = false -- cooldown
part.Touched:Connect(function(hit)
if inuse then return; end -- return if in use
local Player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if Player then -- checking if target player
inuse = true
local Character = hit.Parent -- find character
Character:PivotTo(workspace.Part.CFrame) -- change way or use local
task.delay(1, function() -- cooldown
inuse = false
end)
end
end)
print("script enabled")
local part = script.Parent
print("first variable")
part.Touched:Connect(function(hit)
local character = hit.Parent
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
print("touched event started")
if humanoidRootPart then
local targetCFrame = game.Workspace.Areas.Area.CFrame
humanoidRootPart.CFrame = targetCFrame
print("teleported")
end
end)
Script is enabled and none of the print statements work?