I'm making a lightning ability sort of thing, and I'm working on the first move. It's supposed to make a ball of lightning appear on the user's hand, kind of like a Chidori if you've seen Naruto, and the user can press the key again to launch the lightning ball and cause an explosion, not so much like a Chidori. The explosion part hasn't been implemented yet, but whenever I try to tween the ball to wherever the mouse is, it just falls through the ground.
I assume this is because it's not anchored and CanCollide is turned off, but even when I make it anchored, it still does it. I'm trying to anchor it from the script that makes it appear, and I used prints to check if it was for some reason doing it locally, even being in a server script, and the prints printed what I wanted to happen, but the ball just falls.
Server:
-- Replicated Storage
local repStorage = game:GetService("ReplicatedStorage")
local powers = repStorage:WaitForChild("Powers")
local lightningEvents = powers:WaitForChild("Lightning")
local rEvent = lightningEvents:WaitForChild("R")
local tEvent = lightningEvents:WaitForChild("T")
local vEvent = lightningEvents:WaitForChild("V")
-- Events
rEvent.OnServerEvent:Connect(function(player,enabled,mouseCFrame)
-- Player Stuff
local char = player.Character
local rightHand = char:WaitForChild("RightHand")
-- Meshes
local lightningBall = script:WaitForChild("Lightning Ball"):Clone()
local boom1 = script:WaitForChild("Boom1"):Clone()
local boom2 = script:WaitForChild("Boom2"):Clone()
if enabled == false then
-- Setting Positions
lightningBall.CFrame = rightHand.CFrame + rightHand.CFrame.upVector*-5
lightningBall.Parent = game.Workspace
-- Welding
weld = Instance.new("Weld",rightHand)
weld.Part0 = rightHand
weld.Part1 = lightningBall
elseif enabled == true then
local tweenService = game.TweenService
local tweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In,
0,
false
)
local partProperties = {
CFrame = mouseCFrame
}
print(lightningBall.Anchored)
weld:Destroy() -- Destroys the weld.
lightningBall.Anchored = true -- Makes the ball anchored . . . supposedly.
print(lightningBall.Anchored)
local tween = tweenService:Create(lightningBall,tweenInfo,partProperties)
tween:Play() -- Is there just something wrong with my tween?
end
end)
-- Beyond this is just stuff for the other moves, they're still being made.
tEvent.OnServerEvent:Connect(function(player)
end)
vEvent.OnServerEvent:Connect(function(player)
end)
Client:
-- Player Stuff
local player = game.Players.LocalPlayer
local char = player.Character
local humanoid = char:WaitForChild("Humanoid")
local rootPart = char:WaitForChild("HumanoidRootPart")
-- Input
local UIS = game:GetService("UserInputService")
local mouse = player:GetMouse()
-- Replicated Storage
local repStorage = game:GetService("ReplicatedStorage")
local powers = repStorage:WaitForChild("Powers")
local lightningEvents = powers:WaitForChild("Lightning")
local rEvent = lightningEvents:WaitForChild("R")
local tEvent = lightningEvents:WaitForChild("T")
local vEvent = lightningEvents:WaitForChild("V")
-- Stats
local stats = player:WaitForChild("Stats")
local powerStat = stats:WaitForChild("Power")
local power = powerStat:WaitForChild("PowerLevel")
-- Debounces and Cooldowns
local db1 = false
local db2 = false
local db3 = false
local ballCooldown = 10
-- Other
local ballEnabled = false
UIS.InputBegan:Connect(function(input, gameStuff)
if gameStuff then return end
if input.KeyCode == Enum.KeyCode.R and db1 == false then
if ballEnabled == true then
db1 = true
rEvent:FireServer(ballEnabled,mouse.Hit)
wait(ballCooldown)
ballEnabled = false
elseif ballEnabled == false then
rEvent:FireServer(ballEnabled,nil)
ballEnabled = true
end
db1 = false
-- Once again, the next two moves aren't made yet.
elseif input.KeyCode == Enum.KeyCode.T and db2 == false and power.Value >= 50 then
db2 = true
tEvent:FireServer()
db2 = false
elseif input.KeyCode == Enum.KeyCode.V and db3 == false and power.Value >= 100 then
db3 = true
vEvent:FireServer()
db3 = false
end
end)
I might just be doing the tween wrong, but if you could help, I would greatly appreciate it!
Edit: Sorry, I forgot to post a Gyazo of what happens so you can get a better idea of what happens. https://gyazo.com/188a56c2ec2402093795d1e697a04692

4 comments
Are you trying to stop the tween? If so, then tween:Cancel() should do the trick.
Oh yeah, I forgot to put a gyazo of what happens. I'm not trying to stop the tween, because the tween never really does what it's supposed to. I did mention that this was unfinished.
Why does is say "mouseCFrame", shouldn't it be "mouse.CFrame"?
"mouse.Hit" is sent through the Remote Event from the local script, and is put in the parameter mouseCFrame.