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

Making a teleport gui and it won't work? (For Void Script Builder Place 1)

Asked by 4 years ago

So i'm making a teleport gui but, when i click the button to teleport, i get this error; Players.Entity_246.PlayerGui.TP.Frame.LocalScript:6: attempt to index field 'Character' (a nil value)

my script is;

local target = script.Parent.Target.Text
plr = game:GetService("Players").LocalPlayer
char = plr.Character

script.Parent.Fire.MouseButton1Click:Connect(function(Tele)
    char.HumanoidRootPart.Position = game.Players,target.Character.HumanoidRootPart.Position
end)

i already have a script setting a string value to the target.

Extra: This is for Void Script Builder Place One and for my own personal learning.

thanks,

0
Try doing: local character = player.Character or player.CharacterAdded:wait() milkydadup 1 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago
local target = script.Parent.Target.Text
plr = game:GetService("Players").LocalPlayer
char = plr.Character
script.Parent.Fire.MouseButton1Click:Connect(function()
    char.HumanoidRootPart.CFrame = game:GetService("Players")[target].Character.HumanoidRootPart.CFrame
end)

you have to use brackets in order to find someone's character from text in a gui. also using position ONLY teleports the humanoidrootpart, leaving the rest of your character in the same position. use cframe instead.

0
Thank you this is very well explained :) EllaTheFloofyFox 106 — 4y
Ad

Answer this question