Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
iHavoc101 127
4 years ago
Edited 4 years ago

~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

Log in to vote
0
Answered by
cegberry 432 Moderation Voter
4 years ago

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
Ad

Answer this question