Error in script

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I’m trying to make laser script

  2. What is the issue? There’s errors image

  3. What solutions have you tried so far? I have looked on the dev forum

This is the script
image

if Input.KeyCode == Enum.KeyCode Q then

Should be

if Input.KeyCode == Enum.KeyCode.Q then

Also you forgot a . between AudioPlayerModule and playAudio

u meant

Enum.KeyCode.Q?
words limit

Thank you didn’t see that (Ignore this)

1 Like

Anytime! I would recommend taking a very careful look at your code when you see erorrs like those so you know what it is! If you have anymore issues don’t be afraid to make another post!

Yes I will make sure to do that next time

1 Like

Btw what does this mean image

it means that you are trying to find the position of nothing
Either it doesn’t exist or the script can’t find it

Ok can I show you the script? (Ignore this again)

Could you send us the formatted code that you have currently?

Ok (Ignore this need more letters)

local slashbeam = game.ServerStorage:WaitForChild(“slashbeam”)
local damage = 20

game.ReplicatedStorage.Slashbeam.OnServerEvent:Connect(function(player, CFrame)
local character = player.Character
local newskill = slashbeam:clone()
newskill.CanCollide = false
newskill.CFrame = character.HumanoidRootPart.CFrame
local bv = Instance.new(“BodyVelocity”)
bv.MaxForce = Vector3.new(6000,6000,6000)
bv.Velocity = (character.HumanoidRootpart.CFrame.lookvector*240)
bv.Parent = newskill
local playerpostion = (character.HumanoidRootPart.Position)
newskill.Parent = workspace
local skillhit
skillhit = newskill.Touched:connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
if hit.Parent.Name ~= player.Name then
hit.Parent.Humanoid:TakeDamage(damage)
end
end
end)
end)

while wait(0.5) do
local distance = (playerposition - newskill.Position).magnitude
if distance > 60 then
newskill:destroy()
end
end
wait(2)
if skillhit - nil then
skillhit:Disconnect()
end
newskill:Destroy()

The spaces on the ends are messed up

Well I can see that newskill is only declared i nthe RemoteEvent, but you’re trying to get it outside of it, thus a problem occurs, referring to the last bit taht while loop

So how can I fix it? (Ignore this)

That depends what you’re trying to do in your code, you know your code and what you want it to do more than you

I’m following a tutorial (ignore)