- What do you want to achieve?
I have a script that when touched, it morphs you into another character. The character has preset tools that are all clumped into one hand when you first morph. I want the tools to not be in his hand and a simple solution is to add a key press of the number 1 into the script after the morph.
- What is the issue?
I have tried adding key presses into the script but the script either breaks or the key press 1 does not work.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have found a lot of information about how to detect key presses. But can’t find any information on how to make a script press the 1 key. Below is an example of the morph script. At the end I need it to press 1.
local pad = script.Parent
local characterName = "maleelf1"
local character = pad.Parent:WaitForChild(characterName)
local debounce = true
pad.Touched:Connect(function(obj)
local plr = game.Players:GetPlayerFromCharacter(obj.Parent)
if plr and debounce == true then
debounce = false
pad.BrickColor = BrickColor.new("Really red")
local charClone = character:Clone()
charClone.Name = plr.Name
plr.Character = charClone
local rootPart = charClone:FindFirstChild("HumanoidRootPart") or charClone:FindFirstChild("Torso")
local plrRoot = obj.Parent:FindFirstChild("HumanoidRootPart") or obj.Parent:FindFirstChild("Torso")
if rootPart and plrRoot then
rootPart.CFrame = plrRoot.CFrame
end
charClone.Parent = workspace
wait(2.5)
pad.BrickColor = BrickColor.new("Lime green")
debounce = true
end
end)