#[SOLVED] error

1 messages · Page 1 of 1 (latest)

devout ibex
#

i got weird error in my code and idk how to fix this

#

here the code

#

and my other codes in other place got this too

lean lotus
devout ibex
#

nothing

lean lotus
#

usually thats just a visual bug and it goes away after i type something

#

i havent had it stick around for very long

lean lotus
#

if it stays for a while try restarting studio

devout ibex
lean lotus
#

dunno then

#

your script editor is haunted

devout ibex
#

🐒

#

ok

#

i think maybe the new roblox studio theme cause it

#

wait

#

nvm

#

it didn't work

light flame
#

The error is a syntax error in the line Projectile. Velocity = (Hit-Gun.ShootPart.Position). Unit Config.Velocity.Value where Unit should be * for multiplication.

#

This is the corrected code

#
local Gun = script.Parent
local Config = Gun:FindFirstChild("Config")
local Remote = Gun:FindFirstChild("Remote")
local Pir = game:GetService("Players"):GetPlayerFromCharacter(Gun.Parent)
local IsReload = false

Remote.Fire.OnServerInvoke = function(SendPir, Hit)
    if SendPir == Pir then
        return
    end
    local Projectile = Instance.new("Part", workspace.Camera.Projectile)
    Projectile.Size = Vector3.new(1, 1, 1)
    Projectile.Position = Gun.ShootPart.Position
    Projectile.Anchored = true
    Projectile.CanCollide = false
    Projectile.Material = Enum.Material.Neon
    Projectile.Velocity = (Hit - Gun.ShootPart.Position).Unit * Config.Velocity.Value
end
```lua
devout ibex
#

i think not because of "Projectile.Velocity"

devout ibex
#

same thing with my other game

light flame
#

Check for Syntax Errors: Ensure that there are no syntax errors in your code. Sometimes a missing semicolon, bracket, or typo can cause issues.

Review Variable Declarations: Make sure that all variables are properly declared and initialized before you use them. If Projectile is a class or object, ensure it is instantiated correctly.

Look for Null References: If you're trying to access properties or methods on an object that hasn't been instantiated, you'll get a null reference error. Ensure that Projectile is not null before accessing its properties.

Check the Error Message: The error message you receive can provide valuable information about what is going wrong. Look for the line number and the type of error to help narrow down the issue.

Debugging: Use debugging tools or print statements to track the flow of your code and the values of your variables. This can help you identify where things are going wrong.

Consult Documentation: If you're using a game engine or framework, consult the documentation for the correct usage of the classes and methods you're working with.

#

@devout ibex

#

Just lmk

#

if u encountered any prob

devout ibex
#

i think because of the ".unit"

light flame
#

Ig this line is missing

#
lyLinearVelocity (Hit. Position Gun ShootPartPosition) Unit

```lua
#

It seems like the programmer intended to set the velocity based on some direction or value related to the Gun ShootPartPosition.?

#

it seems the issue is with the ".Unit" at the end of the line lyLinearVelocity (Hit. Position Gun ShootPartPosition) Unit

devout ibex
#

i alway use the "Velocity" one but when i update roblox studio its got an underline error and said this

#

nvm

#

the script still work with the weird error on line 1

#

[SOLVED] error

tiny sparrow