I'm trying to teleport the player character to a certain position using CFrame when a player touches an object.
My problem is that the player doesn't CFrame to a postion during online play but in Roblox Studio only, WHY?!
debounce = false
function Touch(Item)
if debounce == true then return end
debounce = true
if Item.Parent:FindFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(Item.Parent) then
local Explosion = Instance.new("Explosion",script.Parent)
local Torso = Item.Parent:FindFirstChild("Torso")
local Humanoid = Item.Parent:FindFirstChild("Humanoid")
Explosion.BlastPressure = 500
Explosion.BlastRadius = 30
Explosion.DestroyJointRadiusPercent = 0
Explosion.Visible = true
Explosion.Position = script.Parent.Position
Torso.Anchored = true
local Step = game:GetService('RunService').Stepped:Connect(function()
Torso.CFrame = script.Parent.CFrame --THIS PART NO WORK!!!
Humanoid.WalkSpeed = 5
end)
wait(0.5)
Step:disconnect()
Torso.Anchored = false
local Refract = Instance.new("BodyPosition",Torso)
Refract.Position = script.Parent.Position + Vector3.new(0,30,0)
Refract.MaxForce = Vector3.new(400000,400000,400000)
Refract.D = 1000
wait(0.5)
debounce = false
Refract:Destroy()
end
end
script.Parent.Touched:Connect(Touch)

1 comment
use BodyPosition