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

How would I go about changing a decal image on a part based on key input?

i want to change a decal image based on key input but sadly i'm facing issues. due to the input script being a LocalScript in StarterGui, it makes me unable to change the decal on a part. i don't have a work-around, and i need help.

3 comments

0

Can you post your script please?

0

Do you want the decal to be changed for all players or only the one who input? If you want all players you can use a RemoteEvent and if you only want the player who input then you can use the LocalScript.

0

only the player who inputs

1 answer

So first you would have to detect the key input like this

local UserInputService = game:GetService("UserInputService")
 
local function onInputEnded(inputObject, gameProcessedEvent)
	-- First check if the 'gameProcessedEvent' is true
	-- This indicates that another script had already processed the input, so this one can be ignored
	if gameProcessedEvent then return end
	-- Next, check that the input was a keyboard event
	if inputObject.UserInputType == Enum.UserInputType.Keyboard then
		print("A key was released: " .. inputObject.KeyCode.Name)
		 if  inputObject.KeyCode.Name == your key string then


		end
	end
end
UserInputService.InputEnded:Connect(onInputEnded) --from dev wiki

docs can be found here https://developer.roblox.com/en-us/articles/introduction-to-input then just use that to change the Decal.Texturn to whatever link you want

local UserInputService = game:GetService("UserInputService")
 
local function onInputEnded(inputObject, gameProcessedEvent)
	-- First check if the 'gameProcessedEvent' is true
	-- This indicates that another script had already processed the input, so this one can be ignored
	if gameProcessedEvent then return end
	-- Next, check that the input was a keyboard event
	if inputObject.UserInputType == Enum.UserInputType.Keyboard then
		print("A key was released: " .. inputObject.KeyCode.Name)
		 if  inputObject.KeyCode.Name == your key string then

			Decal.Texture = "url"
		end
	end
end
UserInputService.InputEnded:Connect(onInputEnded) --from dev wiki

like that

3 comments

0

note this should be in the localscript, and Decal should be the path to it

0

thanks for the help!

0

i have a slight problem. the part i want the decal to be on is inside the player's character under Torso (im using R6.) what would i need to do to get the path to it?

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