to be fair i have no clue how to use remote events and the forum isnt very helpful to me
i have a slapping system i found on the toolbox a year back (its basically a slap battles fangameive made for me and my friends) and ive been using and improving it however each tool has this code repeated but with just increased stats depending on the tool
or maybe instead of remote events i could use modules but then again i have 0 knowledge on that aswell
i will give a sample of the first tool you aquire in the game
its made up of 2 scripts
server and local
heres the server
local tool=script.Parent
local handle=tool:WaitForChild("Handle")
tool:WaitForChild("Event").OnServerEvent:Connect(function(plr,mode,target,velocity)
if mode=="slash" then
local FightMode = target:WaitForChild("HumanoidRootPart"):WaitForChild("FightMode")
if FightMode.Parent == target:WaitForChild("HumanoidRootPart") then
if not target:FindFirstChild("ReverseAbility") and not target:FindFirstChild("TauntG") then
local char = tool.Parent
local slaps = game:GetService("Players"):GetPlayerFromCharacter(char):FindFirstChild("leaderstats"):FindFirstChild("Slaps")
local MS = game:GetService("MarketplaceService")
local gamePassID = 172576245
if MS:UserOwnsGamePassAsync(plr.UserId, gamePassID) then
slaps.Value = slaps.Value + 2
else
slaps.Value = slaps.Value + 1
end
local flingvelocity=velocity*5
local spinvelocity=velocity*0.5
local multipliervelocity=tool:WaitForChild("Power").Value*3
target:FindFirstChildOfClass("Humanoid").PlatformStand=true
local bv=Instance.new("BodyVelocity")
bv.Parent=target:WaitForChild("HumanoidRootPart")
bv.MaxForce=Vector3.new(1e8,1e8,1e8)
bv.Velocity=flingvelocity+Vector3.new(0,multipliervelocity,0)
local bav=Instance.new("BodyAngularVelocity")
bav.Parent=target:WaitForChild("HumanoidRootPart")
bav.AngularVelocity=flingvelocity+Vector3.new(0,multipliervelocity,0)
script.Parent.Handle.MeshPart.hit.Enabled = true
wait(0.1)
script.Parent.Handle.MeshPart.hit.Enabled = false
local sound=Instance.new("Sound")
sound.Parent=target:WaitForChild("HumanoidRootPart")
sound.Volume=3
sound.SoundId="rbxassetid://7195270254"
sound:Play()
wait(tool:WaitForChild("FlightSpeed").Value)
bv:Destroy()
bav:Destroy()
target:FindFirstChildOfClass("Humanoid").PlatformStand=false
sound:Destroy()
elseif target:FindFirstChild("TauntG") then
local offset = Vector3.new(0,0,5)
target.HumanoidRootPart.CFrame = tool.Parent.HumanoidRootPart.CFrame*CFrame.new(offset)
target.HumanoidRootPart.Anchored = true
tool.Parent.HumanoidRootPart.Anchored = true
local folder = game.ReplicatedStorage.TauntGlove
local no = folder.NO:Clone()
no.Parent = target.Head
no:Play()
wait(0.65)
target.HumanoidRootPart.Anchored = false
tool.Parent.HumanoidRootPart.Anchored = false
target:FindFirstChildOfClass("Humanoid"):LoadAnimation(folder:WaitForChild("Slap")):Play()
local char = tool.Parent
local slaps = game:GetService("Players"):GetPlayerFromCharacter(target):FindFirstChild("leaderstats"):FindFirstChild("Slaps")
local MS = game:GetService("MarketplaceService")
local gamePassID = 172576245
if MS:UserOwnsGamePassAsync(target.UserId, gamePassID) then
slaps.Value = slaps.Value + 2
else
slaps.Value = slaps.Value + 1
end
local player = tool.Parent
local flingvelocity=velocity*5
local spinvelocity=velocity*0.5
local multipliervelocity=tool:WaitForChild("Power").Value*3
player:FindFirstChildOfClass("Humanoid").PlatformStand=true
local bv=Instance.new("BodyVelocity")
bv.Parent=player:WaitForChild("HumanoidRootPart")
bv.MaxForce=Vector3.new(1e8,1e8,1e8)
bv.Velocity=flingvelocity+Vector3.new(0,multipliervelocity,0)
local bav=Instance.new("BodyAngularVelocity")
bav.Parent=player:WaitForChild("HumanoidRootPart")
bav.AngularVelocity=flingvelocity+Vector3.new(0,multipliervelocity,0)
script.Parent.Handle.MeshPart.hit.Enabled = true
wait(0.1)
script.Parent.Handle.MeshPart.hit.Enabled = false
local sound=Instance.new("Sound")
sound.Parent=player:WaitForChild("HumanoidRootPart")
sound.Volume=3
sound.SoundId="rbxassetid://7195270254"
sound:Play()
wait(tool:WaitForChild("FlightSpeed").Value)
bv:Destroy()
bav:Destroy()
player:FindFirstChildOfClass("Humanoid").PlatformStand=false
sound:Destroy()
no:Destroy()
elseif target:FindFirstChild("ReverseAbility") then
local char = tool.Parent
local slaps = game:GetService("Players"):GetPlayerFromCharacter(char):FindFirstChild("leaderstats"):FindFirstChild("Slaps")
local MS = game:GetService("MarketplaceService")
local gamePassID = 172576245
if MS:UserOwnsGamePassAsync(plr.UserId, gamePassID) then
slaps.Value = slaps.Value + 2
else
slaps.Value = slaps.Value + 1
end
local flingvelocity=velocity*5
local spinvelocity=velocity*0.5
local multipliervelocity=tool:WaitForChild("Power").Value*3
script.Parent.Parent:FindFirstChildOfClass("Humanoid").PlatformStand=true
local bv=Instance.new("BodyVelocity")
bv.Parent=script.Parent.Parent:WaitForChild("HumanoidRootPart")
bv.MaxForce=Vector3.new(1e8,1e8,1e8)
bv.Velocity=flingvelocity+Vector3.new(0,multipliervelocity,0)
local bav=Instance.new("BodyAngularVelocity")
bav.Parent=script.Parent.Parent:WaitForChild("HumanoidRootPart")
bav.AngularVelocity=flingvelocity+Vector3.new(0,multipliervelocity,0)
script.Parent.Handle.MeshPart.hit.Enabled = true
wait(0.1)
script.Parent.Handle.MeshPart.hit.Enabled = false
local sound=Instance.new("Sound")
sound.Parent=script.Parent.Parent:WaitForChild("HumanoidRootPart")
sound.Volume=3
sound.SoundId="rbxassetid://7195270254"
sound:Play()
wait(tool:WaitForChild("FlightSpeed").Value)
bv:Destroy()
bav:Destroy()
script.Parent.Parent:FindFirstChildOfClass("Humanoid").PlatformStand=false
sound:Destroy()
end
end
elseif mode=="glove" then
script.Parent.Handle.funny_fart1:Play()
end
end)
and the local
local tool=script.Parent
local handle=tool:WaitForChild("Handle")
local mouse=game.Players.LocalPlayer:GetMouse()
local canslap=false
local cd=false
local abilitycd=false
local abilitycooldown=4
local equipped=false
local abilityactivategui=tool:WaitForChild("AbilityActivateButton")
abilityactivategui:WaitForChild("Button").MouseButton1Down:Connect(function()
if equipped==true then
if abilitycd==false then
abilitycd=true
tool:WaitForChild("Event"):FireServer("glove")
abilityactivategui.Button.Text = "Cooldown"
wait(abilitycooldown)
abilityactivategui.Button.Text = "E"
abilitycd=false
end
end
end)
tool.Equipped:Connect(function()
equipped=true
abilityactivategui.Parent=game.Players.LocalPlayer:WaitForChild("PlayerGui")
end)
tool.Unequipped:Connect(function()
equipped=false
abilityactivategui.Parent=tool
end)
tool.Activated:Connect(function()
if cd==false then
cd=true
local multiplier=2.25
local char=game.Players.LocalPlayer.Character
char:FindFirstChildOfClass("Humanoid"):LoadAnimation(tool:WaitForChild("Swing")):Play()
canslap=true
wait(tool:WaitForChild("Speed").Value/multiplier)
canslap=false
wait(tool:WaitForChild("Speed").Value-tool:WaitForChild("Speed").Value/multiplier)
cd=false
end
end)
mouse.KeyDown:Connect(function(key)
if key=="e" then
if equipped==true then
if abilitycd==false then
abilitycd=true
print("ability fired")
tool:WaitForChild("Event"):FireServer("glove")
wait(abilitycooldown)
abilitycd=false
print("ability")
end
end
end
end)
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.ButtonL2 then
if equipped==true then
if abilitycd==false then
abilitycd=true
tool:WaitForChild("Event"):FireServer("glove")
wait(abilitycooldown)
abilitycd=false
end
end
end
end)
handle.Touched:Connect(function(part)
if canslap==true then
if part.Parent:FindFirstChildOfClass("Humanoid") then
canslap=false
local char=game.Players.LocalPlayer.Character
local velocity=char:WaitForChild("HumanoidRootPart").CFrame.LookVector*tool:WaitForChild("Power").Value
tool:WaitForChild("Event"):FireServer("slash",part.Parent,velocity)
end
end
end)
inside the tool is also a remote event called Event
and the ability gui
i just want to optimize this as much as possible but i physically do not know where to start