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

How do you make an image change when you press a key?

I was trying to do a test where, if I press the right key, it changes the image. For some reason the image turns invisible when I press right on my keyboard. Here is the script:

local UIS = game:GetService('UserInputService')
local player = game.Players.LocalPlayer
local Main = script.Parent.Main

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.Right then
		Main.Right.Image = 6654067570
	end
end)

I checked the Output bar, but no errors were shown. Help would be much appreciated!

Here is the actual image that I'm changing as well to prove that it is a correctly typed image:

https://web.roblox.com/library/6654067570/Images-Right-Arrow

1 answer

Nevermind, I figured out:

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.Right then
		Main.Right.Image = 'http://www.roblox.com/asset/?id=6654067556'
	end
end)

This is the code that I actually have to type

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