Ad
Log in to vote
0

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

Asked by 8 days ago
Edited 8 days ago

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

Log in to vote
0
Answered by 8 days ago

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

Ad

Answer this question