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

Every time I press t nothing happens, What did i do wrong?

local Character = Player.Character
local Player = script.Parent.Parent
local cooldown = 5
local canUse = true
local function Clown()
if Key == "t" and canUse == true then
local number = math.random(1,3)
game:GetService("Chat"):Chat(Player.Character.Head, "BDDDDDDDDDDDDDDDDDDD")
wait(3)
game:GetService("Chat"):Chat(Player.Character.Head, "Ding!")
wait(0.5)
canUse = false
game:GetService("Chat"):Chat(Player.Character.Head, "Bad Draw")	
if number == 1 then
game.Lighting["Mace"]:clone().Parent = Player.Backpack
elseif number == 2 then
game.Lighting["Katana"]:clone().Parent = Player.Backpack
elseif number == 3 then
game.Lighting["Scythe"]:clone().Parent = Player.Backpack
end
	end
end
Clown()
canUse = true


1 comment

1 answer

✓ Accepted answer

Well first of all you put an if statement on the very top saying if Key == "t" and canUse == true then this will not let the function go any farther because you never made a Variable called Key so it will just not work. However, if you tried to make it something like if when the Character presses t then the function runs well for that to work first off you need to make it so that the function connects to an event called KeyDown which is now deprecated so you would have to use something like UserInputService or ContextActionService. However, if I were you I'd learn about both of those and then use them to your games benefits. Well, I wish you good luck but, I'd say that if statement is what's preventing the script from working.

Thank you for reading this answer and I hope it helped you out even if it was a little.

~~KingLoneCat

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