So I'm trying to make a laser gun and when I equip the tool and then I click it... it doesn't spawn the laser but, it doesn't give me any errors pls help me.

This is my Local Script >>

local player = game.Players.LocalPlayer

local character = player.Character or player.CharacterAdded:Wait()

local mouse = player:GetMouse()

local tool = game.StarterPack.Tool

	if tool.Equipped == true then
		mouse.Button1Down:Connect(function(clciked)
		game.ReplicatedStorage.LaserGuns.LaserGun1.LaserEvent1:FireServer()
		print("E")
	end)
end

And this is my regular script >>


local Laser = game.ServerStorage.Lasers:WaitForChild("Laser")
game.ReplicatedStorage.LaserGuns.LaserGun1.LaserEvent1.OnServerEvent:Connect(function(player, CFrame)
	
	local tip = game.StarterPack.Tool.Tip
	local newLaser = Laser:Clone()
	
	local bodyVelocity = Instance.new("BodyVelocity")
	bodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
	bodyVelocity.Velocity = (tip.CFrame.lookVector*120)
	bodyVelocity.Parent = newLaser
	
	newLaser.Parent = workspace
	newLaser.Position = tip.Position
	end)

Thx

3 comments

0

You define a parameter as CFrame, but you never pass it along in the FireServer() parenthesis

0

Oh

0

I did now but it still didn't work