I wondered which one I should use for my Movement or Combat System. I have not used tags much, I’ve only played around with attributes for a combat system. If there is something better than both like values or please notify me.
I think it’s better to use Tags to check something, like whether a hitbox is a hitbox, and attributes for a character, like Stunned, Ragdolled, and so on.
Personally I use it like this
But most Battlegrounds use their own States. That is, they create a Configuration in the character and add Value to it using Intance.New. And already local script determines that if there is a file named Stunned in the configuration, it will move slowly
edit:: Important! Values are added from the server script, and the local script determines them.
local script should not change or delete values in any way
You should definitely use attributes over values.
I was wondering about the battle grounds system how would that be used in a script?
The script works like this, when an object named Stunned is found in Configuration States, the character will move slower and will not be able to jump. When an object named Ragdolled is found, the character will not be able to move and will not be able to jump or turn.
The Update function is triggered automatically when any object is added to States, or removed
A local script inside the character is created. And the sample code is written like this:
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait() or script.Parent
repeat wait(0.1)
until Character:FindFirstChildOfClass("Humanoid") and Character:FindFirstChild("HumanoidRootPart") and Character:FindFirstChild("States")
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
local HRP = Character:FindFirstChild("HumanoidRootPart")
local States = Character:FindFirstChild("States")
local function Update()
local WalkSpeed = 16
local JumpPower = 50
local canRotate = true
local canJump = true
if States:FindFirstChild("Stunned") then
WalkSpeed = 5
canJump = false
end
if States:FindFirstChild("Ragdolled") then
WalkSpeed = 0
canRotate = false
canJump = false
end
Humanoid.WalkSpeed = WalkSpeed
Humanoid.JumpPower = JumpPower
Humanoid.AutoRotate = canRotate
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping,canJump)
end
States.ChildAdded:Connect(function()
Update()
end)
States.ChildRemoved:Connect(function()
Update()
end)
To add a stun from a server-side script, all you have to do is do this:
local stunTime = 3
local stun = Instance.new("BoolValue")
stun.Name = "Stunned"
stun.Parent = States
game.Debris:AddItem(stun,stunTime)
Also, to completely remove what you want to remove, just use this and add conditions in the server script
for i,v in pairs(States:GetChildren()) do
if v.Name == "Ragdolled" or v.Name == "Stunned" then
v:Destroy()
end
end
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.