-
What do you want to achieve?
Set a variable as a tween object returned from TweenService:Create(). -
What is the issue?
TweenService:Create() returns nil (or the variable is somehow set to nil).
(Printing the result without setting a variable returns " ") -
What solutions have you tried so far?
Printing the result without setting a variable. Apart from that, I don’t really see much I could try to fix the issue apart from asking on the forums.
here is the function the code in question is in
(the lines im talking about are 104 - 105)
local function attack(info,boring)
_G.c = true
if boring then
local dr = (math.random(2) == 1 and 1 or -1)
BTT.you.CFrame=CFrame.new(dr,103.034,4)
local r = BTT.tb.puck:Clone()
r.Parent = BTT
wai=true
local miss=false
for x = 1,100 do
r.CFrame = CFrame.new(x / 30 * dr - dr,102.875,3)
if not wai then
break
end
if math.abs(r.CFrame.X) > 1.75 then
miss = 1
break
end
task.wait()
end
if miss == 0 or not miss then
for x = 1,5 do
BTT.you.CFrame = BTT.you.CFrame + Vector3.new(0,0,-x / 50)
r.CFrame = CFrame.new(r.Position.X + 1 / 15 * dr,102.875,3)
task.wait()
end
end
miss = (math.abs(r.Position.X-(BTT.you.Position.X)) > 0.5 and 0 or miss)
if miss then
SFX.toss:Play()
else r.Sound:Play()
local bx=(r.Position.X-1*dr)
for x=1,200 do r.CFrame=r.CFrame+Vector3.new(bx,0,-1/2)task.wait()
if math.abs(r.Position.X)>2 then r.Sound.Pitch=.8 r.Sound:Play() bx=-bx end
if r.Position.Z < -4 then
BTT.npc.cool.Value = math.max(0,BTT.npc.cool.Value - require(game.ReplicatedStorage.pucks[stat[4]].effect):effect() / 2)
SFX.hit:Play()
r:Destroy()
r = nil
BTT.tb.y.BrickColor = BrickColor.new(Color3.new(1,0,0))
task.wait(0.4)
BTT.tb.y.BrickColor = BrickColor.new(Color3.new(1,1,0))
break
end
end
end
if r then
task.wait(0.6)
r:Destroy()
end
else
BTT.you.CFrame = CFrame.new(0,103.034,4)
local r = BTT.tb.puck:Clone()
r.Parent = BTT
r.CFrame = CFrame.new(0,102.875,3)
wai = true
repeat task.wait() until not wai
for x = 1,5 do
BTT.you.CFrame = BTT.you.CFrame+Vector3.new(0,0,-x / 25)
end
r.Sound:Play()
local miss = false
local vx,vy = math.random(-50,50) / 1000,-0.1
BTT2[5] = 1
repeat--tennis ball go against the wall
r.CFrame = r.CFrame+Vector3.new(vx,0,vy)
if math.abs(r.Position.X)>1.8 then
vx = -vx
r.CFrame = r.CFrame + Vector3.new(vx,0,0)
r.Sound:Play()
end
if r.Position.Z > 3.4 then--you
if math.abs(BTT.you.Position.X-r.Position.X) < 1 then
vy = -vy - 0.01
r.Sound:Play()
vx = (r.Position.X-BTT.you.Position.X) * 0.3
r.CFrame = CFrame.new(r.Position.X,r.Position.Y,3.4)
elseif r.Position.Z > 4.12 then
miss = true
break
end
elseif r.Position.Z < -3.4 then--opp
if math.abs(BTT.opp.Position.X-r.Position.X) < 1 then
vy = -vy + 0.01
r.CFrame = r.CFrame + Vector3.new(0,0,vy)
vx = (r.Position.X-BTT.opp.Position.X) * 0.3
r.Sound:Play()
else
miss = false
break
end
end
vx *= 0.98
mallet = game.TweenService:Create(BTT.opp,TweenInfo.new(info.malletdelay.Value,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0),{CFrame = CFrame.new(r.Position.X + (math.sin(tick()) + math.random(-100,100) / 100) / 100,103.034,-4)}):Play()
print(mallet)
task.wait()
until miss
if miss then
cool=math.max(0,cool - require(game.ReplicatedStorage.pucks[stat[4]].effect):effect())
SFX.hit:Play()
else BTT.npc.cool.Value = math.max(0,BTT.npc.cool.Value - require(game.ReplicatedStorage.pucks[stat[4]].effect):effect())
SFX.hit:Play()
end
_G.c = false
BTT2[5] = false
r:Destroy()
end
end