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

Help with changing image if a player is on a certain device?

Hello, I need some help with this LocalScript inside a BillboardGui to change the Parent's (ImageButton) Image depending on what device the player is on. There are no errors, and nothing happens.

local uis = game:GetService('UserInputService')
local mobile = uis.TouchEnabled
local console = uis.GamepadEnabled
local pc = not (mobile or console)

if mobile then
    script.Parent.Image = ("rbxassetid://995969403")
	script.Parent.MouseButton1Down:Connect(function(Player)
	script.Parent.Image = ("rbxassetid://995969938")
	end)
	script.Parent.MouseButton1Up:Connect(function(Player)
	script.Parent.Image = ("rbxassetid://995969403")
	end)
else
	if console then
	script.Parent.Image = ("rbxassetid://995987760")
	script.Parent.MouseButton1Down:Connect(function(Player)
	script.Parent.Image = ("rbxassetid://995988254")
	end)
	script.Parent.MouseButton1Up:Connect(function(Player)
	script.Parent.Image = ("rbxassetid://995987760")
	end)
	else
	if pc then
	script.Parent.Image = ("rbxassetid://995986660")
	script.Parent.MouseButton1Down:Connect(function(Player)
	script.Parent.Image = ("rbxassetid://995987092")
	end)
	script.Parent.MouseButton1Up:Connect(function(Player)
	script.Parent.Image = ("rbxassetid://995986660")
	end)
		end
end

2 comments

0

Read my bio.

0

Your bio has nothing to do with this problem. And that comment is getting dead annoying to read on every question I see.

1 answer

local uis = game:GetService('UserInputService')
local mobile = uis.TouchEnabled
local console = uis.GamepadEnabled
local pc = not (mobile or console)

if mobile then
    script.Parent.Image = ("rbxassetid://995969403")
    script.Parent.MouseButton1Down:Connect(function(Player)
   		script.Parent.Image = ("rbxassetid://995969938")
	end)
    script.Parent.MouseButton1Up:Connect(function(Player)
    	script.Parent.Image = ("rbxassetid://995969403")
    end)
elseif console then
    script.Parent.Image = ("rbxassetid://995987760")
    script.Parent.MouseButton1Down:Connect(function(Player)
    	script.Parent.Image = ("rbxassetid://995988254")
	end)
    script.Parent.MouseButton1Up:Connect(function(Player)
   	 script.Parent.Image = ("rbxassetid://995987760")
    end)
    else
    script.Parent.Image = ("rbxassetid://995986660")
    script.Parent.MouseButton1Down:Connect(function(Player)
    	script.Parent.Image = ("rbxassetid://995987092")
    end)
    script.Parent.MouseButton1Up:Connect(function(Player)
   		script.Parent.Image = ("rbxassetid://995986660")
	end)
end

Your ends were wrong all over the place. Studio would have warned you there was an error with eof. I find it hard to believe that there were no errors.

1 comment

0

It is still not working.

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