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

Why doesn't this image button redirect me to another game?

~ImageButton

~~localScript

local TeleportService = game:GetService("TeleportService")
local gameID = 3449790483    --<<Remove This And Put The Second Game "ID"<<
 
function onTouched(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
        TeleportService:Teleport(gameID, player)
    end
end
 
script.Parent.MouseButton1Click(onTouched)

1 answer

✓ Accepted answer

Your trying to get the player from a characters model in ImageLabel, when they touch the part, however ImageLabels cannot be touched, as they are in the UI, not in the workspace, so you may want to replace the player variable with

local player = game:GetService("Players").LocalPlayer

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