Hello Developers!
I've made this Raycast gun which depending where you click, a bullet will shoot towards were your mouse Is, the problem Is that even If I use the weapon, It does nothing
Script:
local Tool = script.Parent
Tool.RemoteEvent.OnServerEvent:Connect(function(player,mousePos)
local Raycastparams = RaycastParams:new()
Raycastparams.FilterDescendantsInstances = {player.Character}
Raycastparams.FilterType = Enum.RaycastFilterType.Blacklist
local raycastResault = workspace:Raycast(script.Parent.Handle.Position,(mousePos - script.Parent.Handle.Position)*500, Raycastparams)
if raycastResault then
local NewInstance = raycastResault.Instance
local Posistion = NewInstance:FindFirstAncestorOfClass("Part")
if Posistion then
local HitMark = Instance.new("Part",game.Workspace)
game:GetService("Debris"):AddItem(HitMark,2)
HitMark.Position = Posistion.Position
HitMark.Anchored = true
HitMark.Transparency = 0.5
HitMark.CanCollide = false
HitMark.Size = Vector3.new(0.838, 1, 1.059)
local Bullet = Instance.new("Part",game.Workspace)
game:GetService("Debris"):AddItem(Bullet,5)
Bullet.Position = Tool.Handle
Bullet.CFrame = CFrame.new(Bullet.Position, HitMark.Position)
Bullet.Anchored = true
Bullet.CanCollide = false
Bullet.Size = Vector3.new(0.838, 1, 1.059)
for i=0, 30 do
Bullet.CFrame = Bullet.CFrame + Vector3.new(Bullet.CFrame.LookVector*5)
wait()
end
game:GetService("Debris"):AddItem(Bullet,0)
end
end
end)

1 comment
It looks like you posted server-side code. Do you have a LocalScript? What are its contents? More information needed.