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

Script is killing players?

Asked by
FiredDusk 1466 Moderation Voter
9 years ago

This is kinda killing players when they touch the part.

1part = script.Parent
2 
3function Touched (char)
4    char.Position = Vector3.new(10,10,10)
5 
6end
7 
8script.Parent.Touched:connect(Touched)

5 answers

Log in to vote
2
Answered by 9 years ago

Try Using the moveto function:

01part = script.Parent
02cords = 10, 10, 10 -- put cords here
03local Human = char.Parent:FindFirstChild("Humanoid")
04 
05    local Player = char.Parent
06function Touched (char)
07 
08    Player:MoveTo(Vector3.new(cords))
09 
10end
11 
12script.Parent.Touched:connect(Touched)

Hope i help!

0
Does not work FiredDusk 1466 — 9y
0
I fixed it though. Thanks :) FiredDusk 1466 — 9y
0
There i fixed forgot to include a line. pluginfactory 463 — 9y
0
No problem glad i could help :D pluginfactory 463 — 9y
View all comments (4 more)
0
I fixed YOUR script. You did it wrong, you needed the variables in the function FiredDusk 1466 — 9y
0
oh, ok i made a mistake, but again, glad i could help :D pluginfactory 463 — 9y
0
*stuffs phone cord in variable* What? It said cords! D:< TerrodactyI 173 — 9y
0
0.o That might work... pluginfactory 463 — 9y
Ad
Log in to vote
1
Answered by 9 years ago

Please accept this answer:

It may have to do with humanoid that you got.

0
I'll just give you an upvote. FiredDusk 1466 — 9y
0
Well, Anything is fine. Thanks a lot :). May you please answer my questions because you are awesome. SeptorHD 15 — 9y
0
Omg so old! FiredDusk 1466 — 8y
Log in to vote
0
Answered by 9 years ago

What part of the character are you moving? I would use CFrame on the Torso. That will tp the player to anywhere you want without killing them in the process.

0
Make the script for me please. FiredDusk 1466 — 9y
Log in to vote
0
Answered by
lucas4114 607 Moderation Voter
9 years ago

Use :MoveTo()

1part = script.Parent
2 
3function Touched (char)
4    char:MoveTo(10,10,10)
5 
6end
7 
8script.Parent.Touched:connect(Touched)
0
16:59:42.594 - MoveTo is not a valid member of Part Thats the error FiredDusk 1466 — 9y
0
MoveTo Is only for models. pluginfactory 463 — 9y
Log in to vote
0
Answered by 9 years ago

Unfortunately the method you used to move the character unfortunately moved the character's limbs using the Position property, breaking all joints and killing the player's character.

01local coords = CFrame.new(0,10,0)
02 
03script.Parent.Touched:connect(function(hit)
04    if hit then
05        if hit.Parent then
06            if hit.Parent:FindFirstChild('Humanoid') then
07                if hit.Parent.Humanoid.Torso then
08                    hit.Parent.Humanoid.Torso.CFrame = coords
09                end
10            end
11        end
12    end
13end)

The above code is meant to teleport a player to the specified coordinates without unexpectedly teleporting them on top of a building if you wanted to teleport them inside. That's the problem with MoveTo() and Position.

I hope you find my answer helpful, I live to help (not really).

Answer this question