#need help with script
1 messages · Page 1 of 1 (latest)
server script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local monkeyKingFolder = ReplicatedStorage:WaitForChild("MONKEY KING")
local itemsFolder = monkeyKingFolder:WaitForChild("ITEMS")
local crownTemplate = itemsFolder:WaitForChild("MKcrown")
local staffTemplate = itemsFolder:WaitForChild("MKSTAFF")
local function equipStuff(player)
local character = player.Character
if not character then return end
local rightArm = character:WaitForChild("Right Arm")
local head = character:WaitForChild("Head")
local staff = staffTemplate:Clone()
staff.Name = "MKSTAFF"
staff.Parent = character
local motor = Instance.new("Motor6D")
motor.Name = "MKSTAFF" --
motor.Part0 = rightArm
motor.Part1 = staff
motor.C0 = CFrame.new(-0.051, -1.027, 0) * CFrame.Angles(math.rad(0), math.rad(105), math.rad(145))
motor.C1 = CFrame.new(0, 0, 0)
motor.Parent = rightArm
local crown = crownTemplate:Clone()
crown.Parent = character
local crownMotor = Instance.new("Motor6D")
crownMotor.Part0 = head
crownMotor.Part1 = crown
crownMotor.C0 = CFrame.new(0, 0.6, 0)
crownMotor.Parent = head
staff.CanCollide = false
crown.CanCollide = false
end
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
wait(0.5)
equipStuff(player)
end)
end)
for _, player in pairs(Players:GetPlayers()) do
if player.Character then
wait(0.5)
equipStuff(player)
end
end
local
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local STAFF_IDLE_ANIMATION_ID = "rbxassetid://107535943381611"
wait(1)
local staff = character:FindFirstChild("MKSTAFF")
if staff then
print("STAFF true")
local idleAnimation = Instance.new("Animation")
idleAnimation.AnimationId = STAFF_IDLE_ANIMATION_ID
local idleTrack = humanoid:LoadAnimation(idleAnimation)
idleTrack.Looped = true
idleTrack.Priority = Enum.AnimationPriority.Idle
idleTrack:Play()
print("Animation start")
staff.AncestryChanged:Connect(function()
if not staff:IsDescendantOf(game) then
idleTrack:Stop()
end
end)
else
print("STAFF false")
end
thx you