What do you want to achieve?
A teleport system for admins
What is the issue?
My script does not work.
localValue and playerValue are player objects.
local localValue = script.Parent.Parent.localValue.Value
local playerValue = script.Parent.Parent.playerValue.Value
local function TeleportTo()
localValue.Character.Torso.CFrame = playerValue.Character.Torso.CFrame
end
local function Bring()
playerValue.Character.Torso.CFrame = localValue.Character.Torso.CFrame
end
script.Parent.To.MouseButton1Down:connect(TeleportTo)
script.Parent.Bring.MouseButton1Click:Connect(Bring)
You need to refer to the actual player objects. Do this by finding it in game.Players. It will return nil if the player is not in the game.
local localValue = game.Players:FindFirstChild(script.Parent.Parent.localValue.Value)
local playerValue = game.Players:FindFirstChild(script.Parent.Parent.playerValue.Value)
But both ObjectValues contain a player object.
(It doesn’t work with your solution)
As soon as a player leaves, the entire Frame will be deleted. The Frame is just a part from a playerlist.
localValue is the LocalPlayer (that’s all the LocalScript inside of it does).
And the playerValue is the player that joined (every player has its own duplicated frame).
Why? It’s a script that knows both the LocalPlayer (via playerValue) and the other player (playerValue). And then the script changed the positions of the torsos.
But it does not work currently and I don’t know why
You can use scripts that run functions after a button is pressed. And also playerValue is getting the player object from the LocalScript inside of it.
Also, the video does not show how to teleport a player to the player, who is clicking the button.
I do know scripting (except for very advanced situations, e.g. modules). But I have trouble solving this problem. Maybe you can give me example code that might solve my problem.
Try running your script inside a LocalScript so you can actually detect the events. I think users have network ownership over their character so they will be able to move themselves just not other admins to them.
It’s a player list and the handler enables the script as soon as the frame gets duplicated and all the informations are getting filled up.
Basically, another script enables it.
First make a local script in the teleport frame. After that put a remote event ( DO NOT RENAME IT )
in the teleport frame. Then put this code in the local script:
local localValue = script.Parent.Parent.localValue.Value
local playerValue = script.Parent.Parent.playerValue.Value
local function TeleportTo()
script.Parent.RemoteEvent:FireServer(localValue.Character.Torso.CFrame,playerValue.Character.Torso.CFrame)
end
local function Bring()
script.Parent.RemoteEvent:FireServer(playerValue.Character.Torso.CFrame,localValue.Character.Torso.CFrame)
end
script.Parent.To.MouseButton1Down:connect(TeleportTo)
script.Parent.Bring.MouseButton1Click:Connect(Bring)
Then in the normal script put this:
script.Parent.RemoteEvent.OnServerEvent:Connect(function(v, t)
v = t
end)