Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why isn't this dialog place teleportation script working?

So I was trying to make a dialog choice that will teleport you to another place, so my script goes like this..

Dialog=script.Parent
Dialog.DialogChoiceSelected:connect(function(Player, Choice)
if Choice == Dialog.DialogChoice1.DialogChoice2.DialogChoice3.DialogChoice4.DialogChoice5.DialogChoice6.DialogChoice7.DialogChoice8.DialogChoice9.DialogChoice10.DialogChoice11.DialogChoice12.DialogChoice13.DialogChoice14 then
local player = game.Players:GetPlayerFromCharacter()
    local placeid = 376013578 
    local spawn = "meme"
	game.workspace.deathsound:Play()
	game.Players.Player.Character.Humanoid:TakeDamage(99)
	game:GetService("TeleportService"):TeleportToSpawnByName(placeid, spawn, player)
end
end)

So what's wrong with this script? In the output it's saying arguement invalid but I have no idea what that means :/

1 comment

0

What line is the error on? We need full details.

1 answer

✓ Accepted answer

From what I can see you do not get the player object so on line 9 player would be nil, you do not use the Player arg passed in the function so the you have no player to teleport.

Example:-

local Dialog = script.Parent
local placeid = 376013578 
local spawnName = "meme"
-- you may need to use wait for child but idk your setup
local teleportChoice = Dialog.DialogChoice1.DialogChoice2.DialogChoice3.DialogChoice4.DialogChoice5.DialogChoice6.DialogChoice7.DialogChoice8.DialogChoice9.DialogChoice10.DialogChoice11.DialogChoice12.DialogChoice13.DialogChoice14

Dialog.DialogChoiceSelected:connect(function(plr, choice)
	if choice == teleportChoice then
		local plrModel = game.Workspace:FindFirstChild(plr.Name)
		if plrModel then
			plrModel.Humanoid:TakeDamage(99)
			game:GetService("TeleportService"):TeleportToSpawnByName(placeid, spawnName, plr) -- we need the player object
		end
	end
end)

I hope this helps.

This discussion is preserved as it was. New answers, comments, and votes are closed.