I have an issue with a script here that works when I’m using it on the PC Version of my game. However when I attempt to use it on mobile they are not working.
wait(1)
player = game.Players.LocalPlayer
button = script.Parent
local plrStage = game.Players.LocalPlayer.leaderstats.Stage.Value
local debounce = false
function teleport()
if not debounce then
debounce = true
local hrp = player.Character.HumanoidRootPart
local stage = game.Players.LocalPlayer.leaderstats.Stage
if stage.Value ~= 0 then
local part = workspace.ObbyStages:FindFirstChild(stage.Value)
hrp.CFrame = part.CFrame + Vector3.new(0,5,0)
end
end
end
button.MouseButton1Click:Connect(teleport)
while true do wait()
debounce = false
wait(1)
end
I have an inventory system that functions the same way and I can equip/unequip my pets, but my teleports aren’t working. Any suggestions?
Just to reiterate, it works on PC, But Mobile teleports are not working.
I’m not sure, because I’ve never made a game for mobile, but I think you have to do something else for mobile. I think instead of .MouseButton1Click, it was .Tapped or something. Let me look on the dev hub for it.
wait(1)
player = game.Players.LocalPlayer
button = script.Parent
local plrStage = game.Players.LocalPlayer.leaderstats.Stage.Value
local debounce = false
function teleport()
if not debounce then
debounce = true
local hrp = player.Character.HumanoidRootPart
local stage = game.Players.LocalPlayer.leaderstats.Stage
if stage.Value ~= 0 then
local part = workspace.ObbyStages:FindFirstChild(stage.Value)
hrp.CFrame = part.CFrame + Vector3.new(0,5,0)
end
end
end
button.MouseButton1Click:Connect(function(teleport)
while true do wait()
debounce = false
wait(1)
end
Hey, you’re right. .Activated seems to work on both devices. Well, this is something I haven’t seen before. If I ever make a mobile game, I’ll be using this. Guess I learned something new.
As I’m new to the GuiButton.Activate I’m unsure how to incorporate it into my script. But once I figure it out I’ll mark it as the solution if it works for me.