local replicatedStorage = game:GetService(“ReplicatedStorage”)
local debris = game:GetService(“Debris”)local shakeEvent = game.ReplicatedStorage.ShakeEvent
local noAmmo = game.ReplicatedStorage.noAmmo
local fireEvent = game.ReplicatedStorage.pow
local reloadSoundEvent = game.ReplicatedStorage.Reload
local glareEvent = game.ReplicatedStorage.Glare
local unglareEvnet = game.ReplicatedStorage.unGlare
local visualsfolder = game.Workspace.visuallocal function createVisual(startPosition, direction)
local centerPoint = startPosition + direction / 2
local distance = direction.Magnitudelocal visual = Instance.new(“Part”)
visual.Parent = visualsfolder
visual.Anchored = true
visual.CanCollide = false
visual.BrickColor = BrickColor.new(“Neon orange”)
visual.Material = Enum.Material.Neonvisual.CFrame = CFrame.new(centerPoint, startPosition)
visual.Size = Vector3.new(0.5,0.5, distance)visual.Transparency = 1
debris:AddItem(visual, .3)
endfireEvent.OnServerEvent:Connect(function(player, tool, startPosition, endPosition, rpg)
local range = tool:GetAttribute(“Range”)
local damage = tool:GetAttribute(“Damage”)
local headshotDamage = tool:GetAttribute(“HeadshotDamage”)
local power = tool:GetAttribute(“Power”)
local smoke = tool.Start.SmokeshakeEvent:FireClient(player, 0.25, 10)
local direction = (endPosition - startPosition).Unit * range
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Excludelocal accessoryBlacklist = {}
for _, plr in pairs(game.Players:GetChildren()) do
if plr ~= player then
if plr.Character then
for _, accessory in pairs(plr.Character:GetChildren()) do
if accessory:IsA(“Accessory”) then
table.insert(accessoryBlacklist, accessory)
end
end
local vest = plr.Character:WaitForChild(“Torso”):FindFirstChild(“Vest”)
if vest then
table.insert(accessoryBlacklist, vest)
end
end
end
endlocal teamBlacklist = {}
for _,plr in pairs(game.Players:GetChildren()) do
if plr ~= player then
if plr.Team == player.Team then
if plr.Character then
table.insert(teamBlacklist,plr.Character)
end
end
end
endraycastParams.FilterDescendantsInstances = {player.Character, game.Workspace.visual, accessoryBlacklist, teamBlacklist}
local raycast = game.Workspace:Raycast(startPosition, direction, raycastParams)
if raycast.Instance == “Terrain” then
end
tool.Handle.Fire:Play()
smoke:Emit(5)
if raycast then
if raycast.Instance thenlocal random = math.random(1,2) if rpg then local boomThing = game.ReplicatedStorage.hit:Clone() local boomWeld = Instance.new("WeldConstraint") boomWeld.Part0 = raycast.Instance boomWeld.Part1 = boomThing boomThing.CFrame = CFrame.new(raycast.Position, raycast.Position + raycast.Normal) boomWeld.Parent = raycast.Instance boomThing.Parent = raycast.Instance local explosion = Instance.new("Explosion") explosion.Parent = boomThing explosion.Position = boomThing.Position explosion.ExplosionType = Enum.ExplosionType.Craters explosion.DestroyJointRadiusPercent = 0 explosion.BlastRadius = 10 explosion.BlastPressure = 100 boomThing.BOOM:Play() explosion.Hit:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then if random == 1 then hit.Parent.Humanoid.Health -= 75 else hit.Parent.Humanoid.Health = 0 end end end) game.Debris:AddItem(boomWeld, 2) else print(raycast.Instance:GetFullName()) local hitCharacter = raycast.Instance.Parent local humanoid = hitCharacter:FindFirstChild("Humanoid") if humanoid then if hitCharacter.Name ~= player.Character.Name and hitCharacter.name ~= tool.Name then local hit = tool.Handle.Hit:Clone() local deltaPosition = raycast.Position - raycast.Instance.Position local blood = game.ReplicatedStorage.blood:Clone() local weld = Instance.new("WeldConstraint") weld.Part0 = raycast.Instance weld.Part1 = blood blood.CFrame = CFrame.new(raycast.Position, raycast.Position + raycast.Normal) weld.Parent = raycast.Instance blood.Parent = raycast.Instance blood.ParticleEmitter:Emit(5) hit.Parent = hitCharacter.HumanoidRootPart hit:Play() game.Debris:AddItem(hit , 1) if raycast.Instance.Name == "Head" then --local headshothighlight = Instance.new("Highlight") --headshothighlight.FillColor = Color3.new(1, 0, 0) --headshothighlight.OutlineColor = Color3.new(0.666667, 0, 0) --headshothighlight.Parent = raycast.Instance humanoid.Health -= headshotDamage raycast.Instance.Parent.HumanoidRootPart.Velocity = player.Character.HumanoidRootPart.CFrame.LookVector * power --headshothighlight.DepthMode = "Occluded" --task.wait(0.05) --headshothighlight:Destroy() else if raycast.Instance.Name == "HumanoidRootPart" then --local roothighlight = Instance.new("Highlight") --roothighlight.FillColor = Color3.new(1, 0.333333, 0) --roothighlight.OutlineColor = Color3.new(0.721569, 0.239216, 0) --roothighlight.Parent = raycast.Instance.Parent.Torso --roothighlight.DepthMode = "Occluded" humanoid.Health -= damage raycast.Instance.Parent.HumanoidRootPart.Velocity = player.Character.HumanoidRootPart.CFrame.LookVector * power --task.wait(0.05) --roothighlight:Destroy() else --local highlight = Instance.new("Highlight") --highlight.FillColor = Color3.new(1, 0.333333, 0) --highlight.OutlineColor = Color3.new(0.721569, 0.239216, 0) --highlight.Parent = raycast.Instance --highlight.DepthMode = "Occluded" humanoid.Health -= damage raycast.Instance.Parent.HumanoidRootPart.Velocity = player.Character.HumanoidRootPart.CFrame.LookVector * power --task.wait(0.05) --highlight:Destroy() end end end else local hitThing = game.ReplicatedStorage.hit:Clone() local hitWeld = Instance.new("WeldConstraint") hitWeld.Part0 = raycast.Instance hitWeld.Part1 = hitThing hitThing.CFrame = CFrame.new(raycast.Position, raycast.Position + raycast.Normal) hitWeld.Parent = raycast.Instance hitThing.Parent = raycast.Instance hitThing.ParticleEmitter.Color = ColorSequence.new(raycast.Instance.Color) if raycast.Instance:IsA("Terrain") then local hitPosition = raycast.Position local terrain = workspace.Terrain
> local materialColor = terrain:GetMaterialColor(raycast.Instance.Material.Color3.fromRGB())
hitThing.ParticleEmitter.Color = ColorSequence.new(materialColor)
else
hitThing.ParticleEmitter.Color = ColorSequence.new(raycast.Instance.Color)
endend end
end
endcreateVisual(startPosition, direction)
end)noAmmo.OnServerEvent:Connect(function(player, tool)
tool.Handle.Click:Play()
end)reloadSoundEvent.OnServerEvent:Connect(function(player, tool)
task.wait(1)
tool.Handle.Mag.Transparency = 0
end)
how do i check the color of the terrain i hit? i bolded where i get the materials color