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

Howcome this script does not teleport the player to the spawn once they have hit the object?

Asked by 4 years ago
function Touch(hit)
    local Tor = hit.Parent:FindFirstChild("Torso")
    local Spawn = game.Workspace.Stages:FindFirstChild("1")
    local hum = hit.Parent:FindFirstChild("Humanoid")

    if Tor then
    if hum then
    hum.WalkSpeed = 16
    Tor.Position = Spawn.Position
    end
    end
    end

script.Parent.Touched:Connect(Touch)

2 answers

Log in to vote
0
Answered by 4 years ago

I guess you should change the CFrame of the Humanoid Root Part to the spawn's CFrame like this:

function Touch(hit)
    local Spawn = game.Workspace.Stages:FindFirstChild("1")
    local parent = hit.Parent --Getting the parent of the part that touched the brick
    if game.Players:GetPlayerFromCharacter(parent) then --Checking if the parent is a player's character
        parent.HumanoidRootPart.CFrame = Spawn.CFrame + Vector3.new(0,5,0) --Changin the humanoid root part CFrame to the spawn CFrame plus 5 studs up so the player doesnt get stuck on the floor
    end
end

script.Parent.Touched:Connect(Touch)
0
Or use :SetPrimaryPartCFrame(). youtubemasterWOW 2741 — 4y
0
I get what you did, but howcome your method would work but not mine? Don't they do the same thing? IAmSoloz 14 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

script.Parent.Touched:Connect(function(h) local hum = h.Parent:FindFirstChild('Humanoid') if hum ~= nil then h.Parent.HumanoidRootPart.CFrame = CFrame.new(workspace.Stages.StageOne.Position) end end)

Answer this question