Unable to cast value to Object

im trying to make teleport system that takes the full power or anyone in the party but im failing
the values the players names are on is an ObjectValue how can i fix this issue to teleport them

	Option1 = {"Party Teleport", "Enjoy.", 
			func = function(plr)
				local Gravity_Chamber = 10539033270
				local partymembers = {}
				local Stats = MainModule.GetStats(plr)    
				local Players = game:GetService("Players")
				local MyPartyFolder = game.ReplicatedStorage.Parties:FindFirstChild(plr.Name)

				if Stats.Zeni.Value >= Price then
					Stats.Zeni.Value = Stats.Zeni.Value - Price
					if MyPartyFolder.Player2.Value ~= "" then partymembers = {Players:FindFirstChild(MyPartyFolder.Player1.Value), Players:FindFirstChild(MyPartyFolder.Player2.Value)} end
				--	if MyPartyFolder.Player3.Value ~= "No One" then partymembers = {Players:FindFirstChild(MyPartyFolder.Player1.Value), Players:FindFirstChild(MyPartyFolder.Player2.Value), Players:FindFirstChild(MyPartyFolder.Player3.Value) }return end
				--	if MyPartyFolder.Player4.Value ~= "No One" then partymembers = {Players:FindFirstChild(MyPartyFolder.Player1.Value), Players:FindFirstChild(MyPartyFolder.Player2.Value), Players:FindFirstChild(MyPartyFolder.Player3.Value), Players:FindFirstChild(MyPartyFolder.Player4.Value) }return end
					
					game:GetService("TeleportService"):Teleport(Gravity_Chamber,partymembers) -- the part saying Unable to cast value to Object
				end
			end
		},
1 Like

Look at how this function works: TeleportService:TeleportAsync(placeid, players)

ye did all this so now im asking for help

You’re passing a list of players in :Teleport(), which you can’t do. Only :TeleportAsync() can do that.

also i haven’t been to sleep in over 17 hours I been scripting none stop and this is an issue i came across while scripting so i decided to ask for help after trying many ways

i’ll see if this works again if not i’ll tell you

Option1 = {"Party Teleport", "Enjoy.", 
	func = function(plr)
		local partymembers = {}
		local Stats = MainModule.GetStats(plr)    
		local myparty = game.ReplicatedStorage.Parties:FindFirstChild(plr.Name)

		if Stats.Zeni.Value >= Price then
			Stats.Zeni.Value = Stats.Zeni.Value - Price
			if myparty.Player1.Value ~= "" and myparty.Player2.Value ~= "" then
				partymembers = {
					game.Players:FindFirstChild(myparty.Player1.Value),
					game.Players:FindFirstChild(myparty.Player2.Value)
				}
			end
			-- if MyPartyFolder.Player3.Value ~= "No One" then partymembers = {Players:FindFirstChild(MyPartyFolder.Player1.Value), Players:FindFirstChild(MyPartyFolder.Player2.Value), Players:FindFirstChild(MyPartyFolder.Player3.Value) }return end
			-- if MyPartyFolder.Player4.Value ~= "No One" then partymembers = {Players:FindFirstChild(MyPartyFolder.Player1.Value), Players:FindFirstChild(MyPartyFolder.Player2.Value), Players:FindFirstChild(MyPartyFolder.Player3.Value), Players:FindFirstChild(MyPartyFolder.Player4.Value) }return end
			
			game.TeleportService:TeleportAsync(10539033270,partymembers)
		end
	end
},

will i do player3 and player 4 like this? if I wanna take all four player or three players

if myparty.Player1.Value ~= "" and myparty.Player2.Value ~= "" then
						partymembers = {
							game.Players:FindFirstChild(myparty.Player1.Value),
							game.Players:FindFirstChild(myparty.Player2.Value)
						}
					end
					if myparty.Player1.Value ~= "" and myparty.Player2.Value ~= ""  and myparty.Player3.Value ~= ""  then
						partymembers = {
							game.Players:FindFirstChild(myparty.Player1.Value),
							game.Players:FindFirstChild(myparty.Player2.Value),
							game.Players:FindFirstChild(myparty.Player3.Value)
						}
					end
					if myparty.Player1.Value ~= "" and myparty.Player2.Value ~= ""  and myparty.Player3.Value ~= "" and myparty.Player4.Value ~= ""  then
						partymembers = {
							game.Players:FindFirstChild(myparty.Player1.Value),
							game.Players:FindFirstChild(myparty.Player2.Value),
							game.Players:FindFirstChild(myparty.Player3.Value),
							game.Players:FindFirstChild(myparty.Player4.Value)
						}
					end```

well it put me at this part


https://gyazo.com/9c7c3c511f1d3b49efdedc9322b01546

how will find if there is a third player or fourth player in party


https://gyazo.com/d24a90ce8f8de1c31e61bb4703db6b78

im getting this

This may not help, but what is your Value inside the player?
If you insert a NumberValue, or similar, shouldn’t you be reading MyPartyFolder.Player2.Value.Value to get the actual number?

thanks for the help i fixed it and now the only issue is making sure it gives the player the time


				if Stats.Zeni.Value >= Price then
					game.ServerStorage.PlayerData[plr.Name].Stats.GCProgress.Value = 3500  --the time
					Stats.Zeni.Value = Stats.Zeni.Value - Price
					if myparty.Player1.Value ~= "" and myparty.Player2.Value ~= "" then
						partymembers = {
							myparty.Player1.Value,
							myparty.Player2.Value
						}
			
					end
					if myparty.Player1.Value ~= "" and myparty.Player2.Value ~= ""  and myparty.Player3.Value ~= ""  then
						partymembers = {
							myparty.Player1.Value,
						myparty.Player2.Value,
							myparty.Player3.Value
						}
					end
					if myparty.Player1.Value ~= "" and myparty.Player2.Value ~= ""  and myparty.Player3.Value ~= "" and myparty.Player4.Value ~= ""  then
						partymembers = {
							myparty.Player1.Value,
							myparty.Player2.Value,
							myparty.Player3.Value,
							myparty.Player4.Value
						

						}
					
			end
					Services.TeleportService:TeleportAsync(10539033270,partymembers)
				end
			end```

i already fixed it just gotta make it gives the time set to give

Then mark your post as the Solution so others won’t try to solve it, and people Searching the forums can find your Solution.

still editing it before i mark so i can show them what was done

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.