Ok, it worked.
But I need to be able to select more than one spell.
Here is my script for detecting and foreign the event:
wait(1)
---- Services ----
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local UserInputService = game:GetService(“UserInputService”)
---- Variables ----
local IceRemote = ReplicatedStorage:WaitForChild(“IceRemote”)
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Handle = script.Parent.Handle
local Light = script.parent.Light
local SpellOffset = script.Parent.SpellOffset
local spellChosen = script.Parent.Parent.Parent:FindFirstChild(“SpellChosen”)
local Humanoid = Character:WaitForChild(“Humanoid”)
local AttackAnimation = Instance.new(“Animation”) – create a new animation object
AttackAnimation.AnimationId = “rbxassetid://4966082049” – put your animation id over the zeroes
---- Settings ----
local CoolDown = true
local tool = script.Parent
local function onEquip()
wait(0.5)
Handle.Transparency = 0
Light.Transparency = 0.3
SpellOffset.Transparency = 0.5
end
local function onUnequip()
Handle.Transparency = 1
Light.Transparency = 1
SpellOffset.Transparency = 1
end
local function onActivate()
if CoolDown then
if spellChosen.Value == "Ice" then
local AttackAnimationStart = Humanoid:LoadAnimation(AttackAnimation)
AttackAnimationStart:Play() -- Starts Attackanimation
wait(0.5)
AttackAnimationStart:Stop()
IceRemote:FireServer()
local newLight = Instance.new("SpotLight",script.Parent.Light)-- Creates the "Spotlight"
newLight.Brightness = 17 -- The brightness of the "Spotlight"
newLight.Range = 12 -- Range of the "Spotlight"
newLight.Face = "Top" -- Tells there the "Spotlight" faces
CoolDown = false -- /Cooldown in 8 seconds
wait(8)
CoolDown = true -- Cooldown is over
end
end
end
local function onDeactivate()
wait(0.2)
script.Parent.Light:FindFirstChild("SpotLight"):Destroy() -- After 0.2 seconds "Spotlight" is destroyed
end
tool.Equipped:Connect(onEquip)
tool.Unequipped:Connect(onUnequip)
tool.Activated:Connect(onActivate)
tool.Deactivated:Connect(onDeactivate)
So, if the ice spell isn’t chosen I want the script to move on and detect if another spell is chosen.
Do you have any suggestions? 