So what I’m trying to achieve here is I want my weapon to be better, as in Roblox classic sword quality. And How Can I make the rest of the tools that I make high quality? I Would Really appreciate tips and I’m not afraid of criticism. If you can please gives some tips in general.
Somethings that I as of right now do not know how to fix is:
When throwing it looks like it lags(I have tried using :SetNetworkOwner
)
Sometimes when it sticks to the player it prevents them from moving which it should not
If it explodes and it’s near enough of the owner to kill it, stop the explosion(tried magnitude but sometimes it does not work)
Here is the server code:
local Debris = game:GetService("Debris")
local Tool = script.Parent
local Star = Tool.Handle
local SendMouseInformationEvent = Tool.SendMouseInformation
local LeastMagnitude = 20
local Debounce = false
local CoolDown = 1
StarConfigurations = {
OutOfNumber = 10;
StarTypes = {
NormalStar = {
StarSpeed = 200;
StarDamage = 20;
StarRotation = 25;
StarColor = Color3.fromRGB(0, 0, 0);
StarMaterial = Enum.Material.Metal;
Chance = 10;
StarSize = Vector3.new(0.05, 2, 2)
};
BombStar = {
StarSpeed = 275;
StarDamage = 100;
StarRotation = 35;
StarColor = Color3.fromRGB(255, 72, 0);
StarMaterial = Enum.Material.Neon;
Chance = 1;
StarSize = Vector3.new(0.05, 2, 2)
};
HugeStar = {
StarSpeed = 150;
StarDamage = 50;
StarRotation = 45;
StarColor = Color3.fromRGB(0, 0, 0);
StarMaterial = Enum.Material.Metal;
Chance = 3;
StarSize = Vector3.new(0.05, 6, 6)
}
}
}
function ConfigureStar(StarTable, MousePosition, Character)
if Debounce then return end
Debounce = true
local ThowingStar = Star:Clone()
local OutOf = math.random(1, StarTable.OutOfNumber)
local IsBomb = false
local IsGiant = false
local FinalColor = Color3.fromRGB(0, 0, 0)
local FinalDamage = 10
local FinalSpeed = 200
local FinalRotation = 25
local FinalMaterial = Enum.Material.SmoothPlastic
local FinalSize = Vector3.new(0.05, 2, 2)
if OutOf <= StarTable.StarTypes.BombStar.Chance then
IsBomb = true
end
if OutOf <= StarTable.StarTypes.HugeStar.Chance then
IsGiant = true
end
if IsGiant then
FinalDamage = StarTable.StarTypes.HugeStar.StarDamage
FinalSpeed = StarTable.StarTypes.HugeStar.StarSpeed
FinalRotation = StarTable.StarTypes.HugeStar.StarRotation
FinalSize = StarTable.StarTypes.HugeStar.StarSize
end
if IsBomb then
FinalColor = StarTable.StarTypes.BombStar.StarColor
FinalDamage = StarTable.StarTypes.BombStar.StarDamage
FinalSpeed = StarTable.StarTypes.BombStar.StarSpeed
FinalRotation = StarTable.StarTypes.BombStar.StarRotation
FinalMaterial = StarTable.StarTypes.BombStar.StarMaterial
end
ThowingStar.Color = FinalColor
ThowingStar.Material = FinalMaterial
game.TweenService:Create(ThowingStar, TweenInfo.new(.01), {Size = FinalSize}):Play()
ThowingStar.Parent = workspace.GearStorage
ThowingStar.CFrame = CFrame.new(ThowingStar.Position, MousePosition)
ThowingStar.Velocity = ThowingStar.CFrame.LookVector * FinalSpeed
local ThrowAnimation = Character.Humanoid:LoadAnimation(workspace.GearAnimations.StarThrowAnimation)
ThrowAnimation:Play()
ThowingStar.CanCollide = true
local BodyAngularVelocity = Instance.new("BodyAngularVelocity")
BodyAngularVelocity.MaxTorque = Vector3.new(4000, 4000, 4000)
BodyAngularVelocity.P = 1250
BodyAngularVelocity.AngularVelocity = Vector3.new(FinalRotation, 0, 0)
BodyAngularVelocity.Parent = ThowingStar
local IsDone = Instance.new("BoolValue")
IsDone.Name = "IsDone"
IsDone.Parent = ThowingStar
ThowingStar.CanCollide = true
Debris:AddItem(ThowingStar, 5)
Debounce = false
local function ThowingStarTouchedFunction(TouchedObject)
if TouchedObject:FindFirstAncestor(Character.Name) or TouchedObject.Name == ThowingStar.Name then return end
local WeldConstraint = Instance.new("WeldConstraint")
WeldConstraint.Parent = ThowingStar
WeldConstraint.Part0 = ThowingStar
WeldConstraint.Part1 = TouchedObject
if TouchedObject.Parent:FindFirstChild("Humanoid") then
local Humanoid = TouchedObject.Parent.Humanoid
Humanoid:TakeDamage(FinalDamage)
end
if IsBomb then
if (Character.PrimaryPart.Position - MousePosition).Magnitude > LeastMagnitude then
local Explosion = Instance.new("Explosion")
Explosion.Position = ThowingStar.Position
ThowingStar:Destroy()
Explosion.Parent = workspace.GearStorage
else
ThowingStar:Destroy()
end
end
end
ThowingStar.Touched:Connect(ThowingStarTouchedFunction)
return StarTable
end
function ThowStar(Player, MousePosition)
local Character = Player.Character
if Character then
if Character:FindFirstChild("Humanoid") then
if Character.Humanoid.Health ~= 0 then
ConfigureStar(StarConfigurations, MousePosition, Character)
end
end
end
end
SendMouseInformationEvent.OnServerEvent:Connect(ThowStar)
Here is the client code:
local LocalPlayer = game.Players.LocalPlayer
local Mouse = LocalPlayer:GetMouse()
local SendMouseInformationEvent = script.Parent
local ThrowingStar = script.Parent.Parent
function OnActivate()
local MousePos = Mouse.Hit.p
SendMouseInformationEvent:FireServer(MousePos)
end
ThrowingStar.Activated:Connect(OnActivate)
I know this is long, but I really need to make this weapon better.