I have a wand and a GUI that gets put inside the Player's PlayerGui on equipped. This GUI will act as a spell changer which will be controlled by the "q" and "e" keys (Like a left to right selection system).
All it does is it changes a NumberVariable as you press q or e then sets the Spells table to that CurrentNumb THEN changes a number value inside the handle of the wand (CurrentSpell is an Object Value which is linked to the number value inside of the handle of the wand) then the script inside of the Wand Tool uses that number to cast the certain spell so if the CurrentNumb was 3 the wand would cast Spell3 with all it's beautiful effects.
HOWEVER it will not work! There is also no output!
I've also confused myself with the if statements checking the current numb. I DO not want Current numb going under 1 and over 4.
Here is the code:
local Player = game.Players.LocalPlayer
repeat wait(.01) until Player.Character
local Mouse = Player:GetMouse()
local CurrentSpell = script.Obj.Value
local Spells = {"Spell1","Spell2","Spell3","Spell4"}
CurrentNumb = 1
Mouse.KeyDown:connect(function(key)
if key == "q" then
if CurrentNumb > 2 and CurrentNumb ~= 0 then
CurrentNumb = CurrentNumb - 1
if Spells[CurrentNumb] == "string" then
CurrentSpell.Value = CurrentNumb
script.Parent.Text = Spells[CurrentNumb]
end
end
elseif key == "e" then
if CurrentNumb <= 4 then
CurrentNumb = CurrentNumb + 1
if Spells[CurrentNumb] == "string" then
CurrentSpell.Value = CurrentNumb
script.Parent.Text = Spells[CurrentNumb]
end
end
end
end)

2 comments
keydown is deprecated lol
Well it works. .-. @UniversalDreams