#how do i set custom humanoid attributs

88 messages · Page 1 of 1 (latest)

quiet steeple
#

local event = game.ReplicatedStorage:WaitForChild("Hit")
local chr = game.StarterPlayer
local plr = game.Players.LocalPlayer
local humanoid = game.Players.LocalPlayer.WaitForChild("humanoid")

event.OnServerEvent:Connect(function(playerhit)
wait(0.3)
print("hit")
end)

#

server scipt btw

deft surge
mossy frigate
quiet steeple
#

yes

mossy frigate
#

to what instance do you want to add the attribute to?

quiet steeple
#

wdym

mossy frigate
#

like to which object to you want to add an attribute to when the event gets fired

quiet steeple
#

the humanoid

#

or plr

mossy frigate
#

the "playerhit" variable humanoid?

quiet steeple
#

whaa

#

so basicly im makeing a boss fighting game and i making it so if im punching it makes a attribute true then false then when attribut true you cant punch

mossy frigate
#

welp if you want to add an attribute just [humanoid]:SetAttribute(name of the attribute, Value)

quiet steeple
#

so

#

like this

mossy frigate
#

so like to the player who punched the boss humanoid

quiet steeple
#

[humanoid]:SetAttribute("isPunching", true)

mossy frigate
#

the name has to be a string but yeah

#

like "isPunching"

quiet steeple
#

oh ok

mossy frigate
#

playerhit.Character.Humanoid:SetAttribute("IsPunching", true)

quiet steeple
#

so that

mossy frigate
#

i guess is what you're looking for?

quiet steeple
#

this is my script

#

local event = game.ReplicatedStorage:WaitForChild("Hit")
local plr = game.Players.LocalPlayer
local humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")

event.OnServerEvent:Connect(function(playerhit)
humanoid:SetAttribute("IsPunching", true) -- Set IsPunching attribute to true
print("IsPunching is set to true")
wait(0.3)
humanoid:SetAttribute("IsPunching", false) -- Set IsPunching attribute back to false after 0.3 seconds
print("IsPunching is set to false")
end)

#

so i replace that

mossy frigate
#

wait wait wait

#

you cant put OnServerEvent in a client script

quiet steeple
#

i put it in a script though

mossy frigate
#

in a serverscript?

quiet steeple
#

yes

mossy frigate
#

theres no localplayer for a server script

quiet steeple
#

and its not local

#

oh

silver citrusBOT
#

studio** You are now Level 10! **studio

mossy frigate
#

ill edit the script for it to work 2 sec

quiet steeple
#

ok thx

mossy frigate
#

event.OnServerEvent:Connect(function(player, playerhit)
    if not player.Character then return end
    
    local humanoid = player.Character:WaitForChild("Humanoid")
    
    humanoid:SetAttribute("IsPunching", true) -- Set IsPunching attribute to true
    print("IsPunching is set to true")
    wait(0.3)
    humanoid:SetAttribute("IsPunching", false) -- Set IsPunching attribute back to false after 0.3 seconds
    print("IsPunching is set to false")
end)```
#

this should work

quiet steeple
#

ok thx

mossy frigate
#

np

quiet steeple
#

wait wanna see my punch scipt tell me if theres anything to inprove

#

local Cooldown = 0.3 -- Change the cooldown as needed
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local userInputService = game:GetService("UserInputService")

-- Function to check if the player is equipping any tool
local function isEquippingAnyTool()
for _, child in pairs(character:GetChildren()) do
if child:IsA("Tool") then
return true
end
end
return false
end

-- Create a function to handle the mouse click event
local function onMouseClick()
if not debounce and not isEquippingAnyTool() then
if script.Combo.Value ~= 4 then
debounce = true
humanoid.WalkSpeed = 5
game.ReplicatedStorage.Hit:FireServer(1)
wait(0.2)
wait(Cooldown)
humanoid.WalkSpeed = 16
debounce = false
elseif script.Combo.Value == 4 then
debounce = true
humanoid.WalkSpeed = 0
wait(0.5)
humanoid.WalkSpeed = 16
wait(2.4)
debounce = false
end
end
end

-- Connect the function to the mouse click event
userInputService.InputBegan:Connect(function(input, isProcessed)
if input.UserInputType == Enum.UserInputType.MouseButton1 and not isProcessed then
onMouseClick()
end
end)

deft surge
#

You can make your isEquipping function shorter like so:

local function isEquippingAnyTool()
  return (character:FindFirstChildOfClass("Tool") and true) or false
end
#

You could also move the debounce setter lines out of your if statements to shorten the script:

local function onMouseClick()
    if not debounce and not isEquippingAnyTool() then
        debounce = true
        if script.Combo.Value ~= 4 then
            humanoid.WalkSpeed = 5
            game.ReplicatedStorage.Hit:FireServer(1)
            wait(0.2)
            wait(Cooldown)
            humanoid.WalkSpeed = 16
        elseif script.Combo.Value == 4 then
            humanoid.WalkSpeed = 0
            wait(0.5)
            humanoid.WalkSpeed = 16
            wait(2.4)
        end
        debounce = false
    end
end
quiet steeple
#

ok thx

deft surge
quiet steeple
#

wait how do i make it so if humanoid:SetAttribute("IsPunching", true) then it stops it from fireing Hit event

deft surge
#

You can use an if statement to check the value with Instance:GetAttribute(key: string).

quiet steeple
#

i tried but idk were to put local function onMouseClick()
if not debounce and not isEquippingAnyTool() then
debounce = true
if script.Combo.Value ~= 4 then
humanoid.WalkSpeed = 5
game.ReplicatedStorage.Hit:FireServer(1)
wait(0.3)
wait(Cooldown)
humanoid.WalkSpeed = 16
elseif script.Combo.Value == 4 then
humanoid.WalkSpeed = 0
wait(0.5)
humanoid.WalkSpeed = 16
wait(2.4)
end
debounce = false
end
end

deft surge
#

You already have another function that calls onMouseClick when the player clicks, though.

quiet steeple
#

But I need to prevent spamming

#

But I’m getting someone to help me right now

quiet steeple
#

@deft surge @mossy frigate i did it

#

wait

#

bruh

#

here

#

@mossy frigate

#

and @deft surge

mossy frigate
#

congrats

#

it looks good

quiet steeple
#

video fps bruh bad

mossy frigate
#

lol

#

that's roblox's record system

quiet steeple
#

fr

#

wanna try

#

it

deft surge
#

My internet is a trumped-up load of horse crap right now since I'm in a farm in the middle of nowhere.

quiet steeple
#

for some reason the map broke

#

bruh

#

wanna try @mossy frigate

mossy frigate
#

cant sorry

quiet steeple
#

ok

mossy frigate
#

but the game looks amazing

#

keep it up

quiet steeple
#

bey

#

bet

quiet steeple
#

yo bro @mossy frigate can you help

#

?

#

function findNearestPlayer(Position)
wait(0.3)
local List = game.Workspace:children()
local Torso = nil
local Distance = 30
local Temp = nil
local char = game.Workspace.fightingdummy
local humanoid = char.Humanoid
local Human = nil
local Temp2 = nil
for x = 1, #List do
Temp2 = List[x]
if (Temp2.className == "Model") and (Temp2 ~= script.Parent) then
Temp = Temp2:findFirstChild("HumanoidRootPart")
Human = Temp2:findFirstChild("Humanoid")
if (Temp ~= nil) and (Human ~= nil) and (Human.Health > 0) then
if (Temp.Position - Position).magnitude < Distance then
Torso = Temp
Distance = (Temp.Position - Position).magnitude
end
end
end
end
return Torso
end

local followtime = 6
local starttime = tick()
local attacktime = 4

local currenttime

local char = script.Parent
local humanoid = char.Humanoid

function stopfollowing()
humanoid:Move(char.HumanoidRootPart.Position)
humanoid.WalkToPart = nil
humanoid.WalkToPoint = char.HumanoidRootPart.Position
end

while true do
local target = findNearestPlayer(script.Parent.HumanoidRootPart.Position)
if target ~= nil then
script.Parent.Humanoid:MoveTo(target.Position, target)
currenttime = tick()
if currenttime -starttime >= followtime then
wait(0.5)
stopfollowing()
wait(attacktime)
starttime = tick()
end

end

end

#

how do i make it so if distance is less than 5 then
function stopfollowing()
humanoid:Move(char.HumanoidRootPart.Position)
humanoid.WalkToPart = nil
humanoid.WalkToPoint = char.HumanoidRootPart.Position
end

quiet steeple
#

nvm that

#

i solved that

#

i need this solved why no damage

#

local TS = game:GetService("TweenService")
local RS = game:GetService("ReplicatedStorage")
local SS = game:GetService("ServerStorage")
local Damage = 15
local vel
local vel2
local anim
local Modules = RS.Modules
local RockModule = require(Modules.RockModulePro)

script.Parent.OnServerEvent:Connect(function(p)
local Character = p.Character
local Humanoid = p.Character:WaitForChild("Humanoid")
local RootPart = p.Character:WaitForChild("HumanoidRootPart")
local Anim = Humanoid:LoadAnimation(script.Animation)
local Bat = RS["hammer tool"].hammer:Clone()
local Joint = RS["hammer tool"].Motor6D:Clone()
Bat.Parent = Character
Joint.Parent = Character["Right Arm"]
Joint.Part0 = Character["Right Arm"]
Joint.Part1 = Bat.WeaponHold
Anim:Play()
Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0
script.Swing:Play()
Anim:GetMarkerReachedSignal("jump"):Connect(function()
vel = Instance.new("BodyVelocity", RootPart)
vel.MaxForce = Vector3.new(1,1,1) * 1000000;
vel.Parent = RootPart
vel.Velocity = Vector3.new(1,1,1) * RootPart.CFrame.LookVector * 70 + RootPart.CFrame.UpVector * 50
vel.Name = "SmallMoveVel"
game.Debris:AddItem(vel,.1)
end)
Anim:GetMarkerReachedSignal("DMG"):Connect(function()
wait(0.1)
script.Hit:Play()
wait(0.1)
local hitbox = Instance.new("Part", workspace.Hitbox)
hitbox.CanCollide = false
hitbox.CanTouch = true
hitbox.Anchored = true
hitbox.Name = "Hitbox"
hitbox.Material = Enum.Material.ForceField
hitbox.Size = Vector3.new(12,12,12)
hitbox.CanQuery = false
hitbox.Transparency = 0.7 --Edit this if you want to see the hitbox (1 is fully invisible, 0 is fully visible)
hitbox.Color = Color3.fromRGB(255, 0, 0)