Ok so my goal is to onActivation of the tool to take away 25 hp and teleport the player.
Problem is it does teleport the player however it makes the invisible/completely transparent and flings them whenever they move.
Are there any alternative solution to the script I made so I can safely teleport the player without it going invisible nor flinging?
01 | local Tool = script.Parent |
02 | local Player = game.Players.LocalPlayer.Character |
03 |
04 | local script = Tool.TeleportScript |
05 |
06 | function onActivation() |
07 | local deb = false |
08 | local x = math.random( 1 , 991 ) |
09 | local y = math.random( 3 , 3 ) |
10 | local z = math.random( 1 , 991 ) |
11 | local newPos = Vector 3. new(x,y,z) |
12 |
13 | if deb = = false then |
14 | deb = true |
15 | local humanoid = game.Players.LocalPlayer.Character:FindFirstChild( "Humanoid" ) |
You Change The Position Of The HumanoidRootPart Since It Has A Motor6D to The Torso. Motor6D Acts Like Welds When You Move Them Using Your Move Tool But You Can Use CFrame! Example:
1 | local function teleportPlayers(availablePlayers,spawns) -- availablePlayers: Table / spawns: part |
2 | for _, plr in pairs (availablePlayers) do |
3 | if plr.Character then |
4 | plr.Character.HumanoidRootPart.CFrame = spawns [ math.random( 1 ,#spawns) ] .CFrame + Vector 3. new( 0 , 5 , 0 ) |
5 | end |
6 | end |
7 | end |
heres how you use the function:
1 | teleportPlayers(Contestants,workspace.Lobby.SpawnLocation:GetChildren()) |
But Before You Do That You Need To Add Every Single Player To A Table:
1 | Contestants = game.Players:GetPlayers() -- returns a table of all the players |
~ --- might work ~~~~~~~~~~~~~~~~ script.Parent.Touched:Connect(function(hit) local player = hit.Parent if player then local torso = player.HumanoidRootPart if torso then torso.Position = Vector3.new(-308.222, 81.791, -1039.963) --- Put your position end end end)
~~~~~~~~~~~~~~~~~