I'm making a script where if you press a certain key from your keyboard, it launches a fireball + an animation. I have that down, but I want it to activate only if a value is true. I'm trying the Changed function, and I'm new to using the Changed function, but the script won't work now. Only the animation can play. Help? (also there's no errors)

--MY SCRIPT--

--// Services \\--
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Debris = game:GetService('Debris')

--// Variables \\--
local Remote = ReplicatedStorage.RemoteEvents.GreenFireBallEvent
local FireBall = ReplicatedStorage.Parts.GreenFireBall

--// Settings \\--
local Damage = 24.25

local ServerDebounces = {}

Remote.OnServerEvent:Connect(function(plr, Mouse)
 if not ServerDebounces[plr] then
  ServerDebounces[plr] = true
  
  local Char = plr.Character or plr.CharacterAdded:Wait()
plr.FireBalls.GreenFireBall.Changed:Connect(function(newValue) -- Where I'm trying to use Change Function.[[
if plr.FireBalls.GreenFireBall.Value == not newValue then
  local FireBallClone = FireBall:Clone()
  FireBallClone.CFrame = Char.HumanoidRootPart.CFrame * CFrame.new(0,0,-3)
  FireBallClone.Parent = workspace
 
  local BodyVelocity = Instance.new("BodyVelocity")
  BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
  BodyVelocity.Velocity = Mouse.lookVector
  BodyVelocity.Parent = FireBallClone
 
  spawn(function()
   for i = 0, 1000 do
    wait()
    FireBallClone.Size = FireBallClone.Size + Vector3.new(0.07,0.07,0.07)
    BodyVelocity.Velocity = Mouse.lookVector*i
   end
  end)
  ServerDebounces[plr] = false
  Debris:AddItem(FireBallClone, 10)
 
  local Debounce = true
  FireBallClone.Touched:Connect(function(h)
   if h.Parent:FindFirstChild('Humanoid') and h.Parent.Name ~= plr.Name and Debounce then   
    Debounce = false   
    local Enemy = h.Parent.Humanoid
    Enemy:TakeDamage(Damage)
    FireBallClone.Transparency = 1
    BodyVelocity:Destroy()
    FireBallClone.Effect.Speed = NumberRange.new(8,8)
    wait(1)
    FireBallClone.Effect.Enabled = false
    wait(1)
    FireBallClone:Destroy()
    wait(3)
    Debounce = true
end
end)
end
end)
end
end)

5 comments

0

Tab this correctly, it's awful to read in this form

0

Is there any chance you can publish it to roblox and allow us to view it in studio? It's hard to find the issue based on the script you provided.

0

The title is event not function

0

Use this to properly indent your script: https://www.roblox.com/library/592898457/Script-indenter