I’m trying to make it where when a player says a certain phrase they will be teleported somewhere.
Right now I have a script in ServerScriptService:
local Players = game:GetService("Players")
local TouchDestination17 = game.Workspace:WaitForChild("TouchDestination17")
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
if message == "/e hi" then
Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart").CFrame = TouchDestination17.CFrame
end
end)
end)
I think everything is okay except it gives me an error:
ServerScriptService.Script:8: attempt to index nil with ‘Character’
local TouchDestination17 = game.Workspace:WaitForChild("TouchDestination17")
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
if message == "/e hi" then
player.LocalPlayer.Character = TouchDestination17.CFrame
end
end)
end)
local PhraseAnswer = "/e hi"
local Place = 1234567 --Place ID
game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
if Message == PhraseAnswer then
game:GetService("TeleportService"):Teleport(Place, Player)
end
end)
end)