Hello , im trying to make a player get teleported to another game but im getting this error unable to cast value to object
this is the script parented to a proximty prompt
local ProximityPrompt = script.Parent
local TeleportService = game:GetService("TeleportService")
local placeId = tonumber(script.Parent.Parent.Gameid.Value)
local gamename = script.Parent.Parent.SurfaceGui.GameName.Text
ProximityPrompt.ActionText = gamename
local function onProximityPromptTrigger(player)
print(player,placeId)
TeleportService:Teleport(player,placeId)
print("Teleportation successful!")
end
ProximityPrompt.Triggered:Connect(onProximityPromptTrigger)
You have viruses in your game probably. Put c:Script into the explorer search bar then look for scripts you didn’t make. Repeat the same process with c:LocalScript
If you want to teleport players to a specific place, then why not store the place’s ID in a constant variable like so:
local TeleportService = game:GetService("TeleportService")
local PLACE_ID = 123456 -- Replace this with the actual place ID
local proximityPrompt = script.Parent
proximityPrompt.Triggered:Connect(function(player)
TeleportService:Teleport(PLACE_ID, player)
end)
Still good to check though. I’m struggling to think of another reason why you’d be teleported to other games. If you decide to open up a new topic I’ll tell you the best way to check for game teleports.
Try running this script in the studio console and see the result.
for _, e in game:GetDescendants() do
if e:IsA("LuaSourceContainer") and (e.Source:lower() :: string):match("teleport%s?service") and (e.Source :: string):lower():match("teleport[%p%a]*") then
print(e:GetFullName() .. " contains teleport")
end
end
Turn off all your suspicious plugins, they may also be causing the problem.
well only the part with proximityprompt contains the script with the teleport , also turned off all my plugins even tho they werent much suspicious , still the same problem