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

[EDITED TITLE] Why isn't this script CFraming the player at all!?

Asked by 7 years ago
Edited 7 years ago

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?!

01debounce = false
02function Touch(Item)
03    if debounce == true then return end
04    debounce = true
05    if Item.Parent:FindFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(Item.Parent)  then
06        local Explosion = Instance.new("Explosion",script.Parent)
07        local Torso = Item.Parent:FindFirstChild("Torso")
08        local Humanoid = Item.Parent:FindFirstChild("Humanoid")
09        Explosion.BlastPressure = 500
10        Explosion.BlastRadius = 30
11        Explosion.DestroyJointRadiusPercent = 0
12        Explosion.Visible = true
13        Explosion.Position = script.Parent.Position
14        Torso.Anchored = true
15        local Step = game:GetService('RunService').Stepped:Connect(function()
View all 31 lines...
0
use BodyPosition   iddash 45 — 7y

2 answers

Log in to vote
0
Answered by 7 years ago

The reason it's not working is that it's immediately disconnecting due to no wait being sent.

1local connection = game:GetService("RunService").Stepped:Connect(function()
2--stuff
3end) --This is in a seperate thread, due to it being an event.
4wait(5) --solution!
5connection:disconnect() --This seems not to be working because of the seperate threads!!!
6Torso.Anchored = false
Ad
Log in to vote
0
Answered by
R_alatch 394 Moderation Voter
7 years ago
Edited 7 years ago
01local Debounce = false
02 
03script.Parent.Touched:Connect(function(Hit)
04    if Debounce then
05        return
06    end
07 
08    Debounce = true
09 
10    local BackupPart = script.Parent:Clone()
11    local Player = game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent)
12 
13    if Player and Player.Character then
14        local Humanoid = Player.Character:FindFirstChild("Humanoid")
15        local Root = Player.Character:FindFirstChild("HumanoidRootPart")
View all 38 lines...

Answer this question