Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
26 views6 pages

MMM

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views6 pages

MMM

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

-- Function to add RadiusPart to a player's character if it doesn't already exist

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

-- Check if the player already has a RadiusPart


if not character:FindFirstChild("RadiusPart") then
-- Create a new part
local radiusPart = Instance.new("Part")
radiusPart.Name = "RadiusPart"
radiusPart.Size = Vector3.new(2, 2, 2) -- Set size of the part
radiusPart.Transparency = 1 -- Make it invisible if needed
radiusPart.Anchored = true -- Anchored to avoid moving
radiusPart.CanCollide = false -- Ensure it doesn't interfere with
collisions

-- Set the position to match the HumanoidRootPart's position


local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
if humanoidRootPart then
radiusPart.CFrame = humanoidRootPart.CFrame
end

-- Parent the part to the character


radiusPart.Parent = character
print("Added RadiusPart to: " .. player.Name)
else
print("Player " .. player.Name .. " already has a RadiusPart.")
end
end

-- Function to get the distance between two positions


function getDistance(pos1, pos2)
return (pos1 - pos2).magnitude
end

-- Function to find all players within a given radius


function findPlayersInRadius(radius)
local playersInRange = {}
local localPlayer = game.Players.LocalPlayer
local localPlayerPos = localPlayer.Character.HumanoidRootPart.Position

-- Loop through all players


for _, player in pairs(game.Players:GetPlayers()) do
-- Skip the local player
if player ~= localPlayer and player.Character then
local targetPart = nil
-- Check if the player has HumanoidRootPart
if player.Character:FindFirstChild("HumanoidRootPart") then
targetPart = player.Character.HumanoidRootPart
-- If no HumanoidRootPart, check for RadiusPart
elseif player.Character:FindFirstChild("RadiusPart") then
targetPart = player.Character.RadiusPart
end

-- If we found a valid part (HumanoidRootPart or RadiusPart)


if targetPart then
local playerPos = targetPart.Position
local distance = getDistance(localPlayerPos, playerPos)

-- Check if the player (via the target part) is within the radius
if distance <= radius then
table.insert(playersInRange, player)
end
end
end
end
return playersInRange
end

-- Main function to handle Deagle logic for each player in radius


function applyDeagleToPlayers()
-- Ensure every player has a RadiusPart before running the script
for _, player in pairs(game.Players:GetPlayers()) do
ensureRadiusPartExists(player)
end

-- Call the function to find players in a 30-stud radius


local playersInRadius = findPlayersInRadius(30)

-- Now apply the Deagle 'args' logic to each player in radius


for _, targetPlayer in pairs(playersInRadius) do
print("Player found within radius: " .. targetPlayer.Name)

-- Define the Deagle 'args' for action


local args = {
[1] = game:GetService("Players").LocalPlayer.Character.Deagle, --
Reference the Deagle weapon
[2] = game:GetService("Players").LocalPlayer,
[3] = targetPlayer.Character.Humanoid, -- Dynamic: Target player's
humanoid
[4] = targetPlayer.Character.HumanoidRootPart, -- Dynamic: Target
player's humanoid root part
[5] = {
[1] = 31, -- Deagle's damage value
[2] = 2.4, -- Some effect multiplier or stat
[3] = true, -- Boolean flag for special conditions
[4] = 14.78100299835205, -- Bullet speed or power
[5] = false, -- Another condition flag
[6] = 10000, -- Max range for Deagle
[7] = 1000 -- Additional power or effect value
},
[6] = {
[1] = 0,
[2] = 0,
[3] = false,
[4] = false,
[5] =
game:GetService("Players").LocalPlayer.Character.Deagle.GunScript_Server.IgniteScri
pt, -- Deagle Ignite Script
[6] =
game:GetService("Players").LocalPlayer.Character.Deagle.GunScript_Server.IcifyScrip
t, -- Deagle Icify Script
[7] = 100, -- Ignition power
[8] = 100 -- Icify power
},
[7] = {
[1] = true, -- Boolean for some additional effect
[2] = 48, -- Deagle-specific parameter (can be anything)
[3] = 1.9 -- Multiplier or effect speed
},
[8] = targetPlayer.Character:FindFirstChild("Head"), -- Dynamic: Target
player's head
[9] = {
[1] = false,
[2] = {
[1] = 1930359546 -- Example ID, can be changed to match your
needs
},
[3] = 1,
[4] = 1.5,
[5] = 1,
[6] =
game:GetService("Players").LocalPlayer.Character.Deagle.GunScript_Local.GoreEffect
-- Deagle Gore Effect
}
}

-- Invoke the server function for each target player

game:GetService("ReplicatedStorage").Remotes.InflictTarget:InvokeServer(unpack(args
))
end
end

-- Listen for player joining the game and add RadiusPart if necessary
game.Players.PlayerAdded:Connect(function(player)
-- Listen for the character spawning
player.CharacterAdded:Connect(function()
ensureRadiusPartExists(player)
end)
end)

-- Optional: Add RadiusPart to players who are already in the game


for _, player in pairs(game.Players:GetPlayers()) do
ensureRadiusPartExists(player)
end
-- Function to add RadiusPart to a player's character if it doesn't already exist
function ensureRadiusPartExists(player)
local character = player.Character or player.CharacterAdded:Wait()

-- Check if the player already has a RadiusPart


if not character:FindFirstChild("RadiusPart") then
-- Create a new part
local radiusPart = Instance.new("Part")
radiusPart.Name = "RadiusPart"
radiusPart.Size = Vector3.new(2, 2, 2) -- Set size of the part
radiusPart.Transparency = 1 -- Make it invisible
radiusPart.Anchored = true -- Anchored to avoid moving
radiusPart.CanCollide = false -- Ensure it doesn't interfere with
collisions

-- Set the position to match the HumanoidRootPart's position


local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
if humanoidRootPart then
radiusPart.CFrame = humanoidRootPart.CFrame
end

-- Parent the part to the character


radiusPart.Parent = character
print("Added RadiusPart to: " .. player.Name)
else
print("Player " .. player.Name .. " already has a RadiusPart.")
end
end

-- Function to get the distance between two positions


function getDistance(pos1, pos2)
return (pos1 - pos2).magnitude
end

-- Function to find all players within a given radius


function findPlayersInRadius(radius)
local playersInRange = {}
local localPlayer = game.Players.LocalPlayer
local localPlayerPos = localPlayer.Character.HumanoidRootPart.Position

-- Loop through all players


for _, player in pairs(game.Players:GetPlayers()) do
-- Skip the local player
if player ~= localPlayer and player.Character then
local targetPart = nil
-- Check if the player has HumanoidRootPart
if player.Character:FindFirstChild("HumanoidRootPart") then
targetPart = player.Character.HumanoidRootPart
-- If no HumanoidRootPart, check for RadiusPart
elseif player.Character:FindFirstChild("RadiusPart") then
targetPart = player.Character.RadiusPart
end

-- If we found a valid part (HumanoidRootPart or RadiusPart)


if targetPart then
local playerPos = targetPart.Position
local distance = getDistance(localPlayerPos, playerPos)

-- Check if the player (via the target part) is within the radius
if distance <= radius then
table.insert(playersInRange, player)
end
end
end
end
return playersInRange
end

-- Main function to handle G17 logic for each player in radius


function applyG17ToPlayers()
-- Ensure every player has a RadiusPart before running the script
for _, player in pairs(game.Players:GetPlayers()) do
ensureRadiusPartExists(player)
end

-- Call the function to find players in a 30-stud radius


local playersInRadius = findPlayersInRadius(30)

-- Now apply the G17 'args' logic to each player in radius


for _, targetPlayer in pairs(playersInRadius) do
print("Player found within radius: " .. targetPlayer.Name)
-- Define the G17 'args' for action
local args = {
[1] = game:GetService("Players").LocalPlayer.Character.G17, --
Reference the G17 weapon
[2] = game:GetService("Players").LocalPlayer,
[3] = targetPlayer.Character.Humanoid, -- Dynamic: Target player's
humanoid
[4] = targetPlayer.Character.HumanoidRootPart, -- Dynamic: Target
player's humanoid root part
[5] = {
[1] = 15, -- G17's damage value
[2] = 1.5, -- Some effect multiplier or stat
[3] = true, -- Boolean flag for special conditions
[4] = 2.9432904720306396, -- Bullet speed or power
[5] = false, -- Another condition flag
[6] = 10000, -- Max range for G17
[7] = 1000 -- Additional power or effect value
},
[6] = {
[1] = 0,
[2] = 0,
[3] = false,
[4] = false,
[5] =
game:GetService("Players").LocalPlayer.Character.G17.GunScript_Server.IgniteScript,
-- G17 Ignite Script
[6] =
game:GetService("Players").LocalPlayer.Character.G17.GunScript_Server.IcifyScript,
-- G17 Icify Script
[7] = 100, -- Ignition power
[8] = 100 -- Icify power
},
[7] = {
[1] = false, -- Boolean for some additional effect
[2] = 16, -- G17-specific parameter (can be anything)
[3] = 1.7 -- Multiplier or effect speed
},
[8] = targetPlayer.Character:FindFirstChild("Head"), -- Dynamic: Target
player's head
[9] = {
[1] = false,
[2] = {
[1] = 1930359546 -- Example ID, can be changed to match your
needs
},
[3] = 1,
[4] = 1.5,
[5] = 1,
[6] =
game:GetService("Players").LocalPlayer.Character.G17.GunScript_Local.GoreEffect --
G17 Gore Effect
}
}

-- Invoke the server function for each target player

game:GetService("ReplicatedStorage").Remotes.InflictTarget:InvokeServer(unpack(args
))
end
end

-- Listen for player joining the game and add RadiusPart if necessary
game.Players.PlayerAdded:Connect(function(player)
-- Listen for the character spawning
player.CharacterAdded:Connect(function()
ensureRadiusPartExists(player)
end)
end)

-- Optional: Add RadiusPart to players who are already in the game


for _, player in pairs(game.Players:GetPlayers()) do
ensureRadiusPartExists(player)
end

-- Call the G17 application logic after ensuring all players have RadiusParts

You might also like