You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
i am trying to make an orbital strike tool, and so far it works only once
What is the issue? Include screenshots / videos if possible!
heres a video of the issue i have
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i tried looking for a solution but didnt find anything unfortunately
heres the script below
--//Variables
local KineticBombardmentTool = script.Parent.Parent
local GetMouse = game.ReplicatedStorage.OrbitalBombardmentFunctions.GetMousePos
local Rod = game.ServerStorage.OrbitalBombardmentModel.Rod
local IsTouching = script.Parent.Variables.IsTouching.Value
local RodClone = Rod:Clone()
--//Script
KineticBombardmentTool.Activated:Connect(function()
local player = game.Players:FindFirstChild(KineticBombardmentTool.Parent.Name)
local RayPart = KineticBombardmentTool.Handle.Ray.Position
local MousePosition = GetMouse:InvokeClient(player)
local FireDirection = (MousePosition - RayPart).Unit * 500
local Rayresult = workspace:Raycast(RayPart, FireDirection)
if Rayresult then
RodClone.Parent = workspace
RodClone.Position = Rayresult.Position + Vector3.new(0,500,0)
while true do
if IsTouching then
task.wait(0.001)
RodClone.Anchored = true
RodClone.Position = Vector3.new(0,-20,0)
else
repeat task.wait(0.001) until IsTouching
end
end
end
end)
RodClone.Touched:Connect(function()
IsTouching = true
end)
I don’t know if its intentional or not but you’re cloning the rod before you actually use the tool.
This means that it’s trying to use the same cloned rod each time.
it was intentional at first because i couldnt get the rod to anchor and stuff, i changed some stuff and now it just does this
heres the script again
--//Variables
local KineticBombardmentTool = script.Parent.Parent
local GetMouse = game.ReplicatedStorage.OrbitalBombardmentFunctions.GetMousePos
local Rod = game.ServerStorage.OrbitalBombardmentModel.Rod
local IsTouching = false
--//Script
KineticBombardmentTool.Activated:Connect(function()
local player = game.Players:FindFirstChild(KineticBombardmentTool.Parent.Name)
local RayPart = KineticBombardmentTool.Handle.Ray.Position
local MousePosition = GetMouse:InvokeClient(player)
local FireDirection = (MousePosition - RayPart).Unit * 500
local Rayresult = workspace:Raycast(RayPart, FireDirection)
if Rayresult then
local RodClone = Rod:Clone()
RodClone.Parent = workspace
RodClone.Position = Rayresult.Position + Vector3.new(0,500,0)
RodClone.Touched:Connect(function()
IsTouching = true
end)
while true do
if IsTouching then
task.wait(0.001)
RodClone.Anchored = true
RodClone.Parent = RodClone.Parent + Vector3.new(0, -20, 0)
else
repeat task.wait(0.001) until IsTouching
end
end
end
end)
You still have just one IsTouching variable that is being used by all rods and once the first one sets it to true, it never gets reset to false. So only the first rod you fire will actually fall, the rest will get Anchored right after they spawn.
Is not valid code. RodClone.Parent is the Workspace instance itself, not a position that you can add a Vector3 to. This is probably spewing mad errors to your output window.
You probably just want to set Anchored = true from inside the RodClone.Touched function, so that it happens independently for each clone, and get rid of IsTouching and the while loop completely. Unanchor the rod right after you clone it, anchor it and do the final position update when it touches something. The function you get when you use Connect is a new anonymous copy of the function for each clone, so state doesn’t get shared across multiple rod clones.