Can't pinpoint error in ability script

Basically I need help with this line of code. It basically shows an error here, but doesn’t really tell me where the error is:

DarkBiscuit.CFrame = iiDarkDar.Character.Torso.CFrame * CFrame.new(0,math.random(-1,1)*6,3*Hi)

If you need the whole script to understand this line, here you go:

local iiDarkDar = script.Parent.Parent
local enabled = true

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
	if not enabled then return end
enabled = false
for Hi = 1,100 do
local DarkBiscuit = Instance.new("Part")
DarkBiscuit.Shape = "Cylinder"
DarkBiscuit.BrickColor = BrickColor.new("Black")
DarkBiscuit.Transparency = 0.7
DarkBiscuit.Size = Vector3.new(40,40,40)
DarkBiscuit.CanCollide = false
DarkBiscuit.Anchored = false
DarkBiscuit.TopSurface = 0 
DarkBiscuit.BottomSurface = 0 
game.Debris:AddItem(DarkBiscuit,1)
DarkBiscuit.Parent = workspace
DarkBiscuit.CFrame = iiDarkDar.Character.Torso.CFrame * CFrame.new(0,math.random(-1,1)*6,3*Hi)
DarkBiscuit.Touched:connect(function(hit)
 hum = hit.Parent:findFirstChild("Humanoid")
   if hum ~= nil and hum.Parent ~= iiDarkDar.Character and hum.Parent:findFirstChild("ItWasHitByIIDark") == nil then
    local deb = Instance.new("IntValue", hum.Parent)
    deb.Name = "ItWasHitByIIDark"
    game.Debris:AddItem(deb,5)
    hum:TakeDamage(30)
    hum.Sit = false
    wait()
   end
end)
wait()
end
enabled = true
end)

So, what’s the error? If I had to guess are you waiting for those instances? :WaitForChild() more specifically

It says hi at the end of the CFrame.new, that’s what may be causing the error. Also, you need to carefully declare the character variable:

local char = player.Character or player.CharacterAdded:Wait() --in case a character is still being loaded
1 Like

I noticed that too, but I thought it was multiplying, good catch.
i saw it as 3*Hi

That “Hi” at the end is supposed to be connected with this line of code:
for Hi = 1,100 do

I cannot be more specific, because studio doesn’t tell me what is wrong with my script, all it says is:

Script ‘ServerScriptService.Script’, Line 19

That’s literally everything it says.

It’d be nice to organize your coding so you could let others see functions, variables and whitespaces would be nice too. the probably is probably because “3Hi” has a number or you are trying to multiply, I’d do 3*Hi.

The form is removing the *, as it’s the italics symbol…

why is “6,3” in italic symbols? Maybe that’s the problem
try this
also, when you use line of code, type `` ` in the start without the space then type lua then tab

iiDarkDar.Character.Torso.CFrame * CFrame.new(0,math.random(-1,1) 6,3*Hi)

Please put your code in a code block so it is more readable.
Also tabbing and indenting helps make the code more understandable.

Code Blocks:
```
-- Code in here
```

EDIT: Is this a localscript?
because if it is you can avoid making a variable for a player
and do game.Players.LocalPlayer

Please use three grave accents to put the code so I can read it.
print(hello)

I am very sorry, I edited the message so it’s more understandable.

1 Like

I’ve just made it more understandable, I am very sorry.
EDIT: Also, it is an additional script for a local script. The local script would fire the remote and the script would react to it.