Hello, i can’t understand why not working please someone help me!
local script:
local tool = script.Parent
local lplr = game:GetService('Players').LocalPlayer
local Remote = script.Parent:WaitForChild("RemoteRock")
local char = lplr.Character
local hum = char:WaitForChild("Humanoid")
local humRp = char:WaitForChild("HumanoidRootPart")
local Anim = script.Parent:WaitForChild("RockAttackAnim")
local Track = hum:LoadAnimation(Anim)
local Debounce = false
local cooldown = 7
local AttackPhase = 1
local OldWalkSpeed = hum.WalkSpeed
local OldJumpHeight = hum.JumpHeight
function OnActivated()
if AttackPhase == 1 and Debounce == false then
Track:Play()
Track:GetMarkerReachedSignal("Stop"):Connect(function()
Track:AdjustSpeed(0)
end)
hum.WalkSpeed = 0
hum.JumpHeight = 0
Remote:InvokeServer('1')
AttackPhase += 1
hum.WalkSpeed = OldWalkSpeed
hum.JumpHeight = OldJumpHeight
elseif AttackPhase == 2 and Debounce == false then
local mouse = lplr:GetMouse()
local mouseP = mouse.Hit.Position
local Vector = Vector3.new(mouseP.X, mouseP.Y, mouseP.Z)
Remote:InvokeServer('2', Vector)
end
end
tool.Activated:Connect(OnActivated)
Server Script:
local TweenService = game:GetService('TweenService')
local RunService = game:GetService('RunService')
local RockRemote = script.Parent.RemoteRock
local Destroyed = false
local DestroyTween = false
RockRemote.OnServerInvoke = function(plr, phase, mouseP)
local Rock = script.Parent.Rock:Clone()
if phase == '1' then
local char = plr.Character
local hum = char.Humanoid
local humRp = char.HumanoidRootPart
local RayParams = RaycastParams.new()
RayParams.FilterType = Enum.RaycastFilterType.Exclude
RayParams.FilterDescendantsInstances = {char}
local rayDirection = Vector3.new(0, -1, 0)
local rayOrigin = humRp.Position
local ray = workspace:Raycast(rayOrigin, rayDirection * 100, RayParams)
if ray then
Rock.Material = ray.Material
Rock.Color = ray.Instance.Color
Rock.Parent = workspace.VFX
Rock.Rotation = Vector3.new(math.random(0,360), math.random(0,360), math.random(0,360))
local BehindPlayer = humRp.Position - humRp.CFrame.LookVector * 5
Rock.Position = Vector3.new(BehindPlayer.X, ray.Position.Y, BehindPlayer.Z)
local randmoSize = math.random(2,5)
TweenService:Create(Rock, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Position = Rock.Position + Vector3.new(0,10,0), Size = Vector3.new(randmoSize,randmoSize,randmoSize)}):Play()
task.wait(1)
local Render
Render = RunService.Stepped:Connect(function()
local random = math.random(0,360)
local tween1 = TweenService:Create(Rock, TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Rotation = Vector3.new(random,random,random)})
coroutine.wrap(function()
while true do
if Destroyed == false then
tween1:Play()
wait(3)
else
break
end
end
end)()
local tween2 = TweenService:Create(Rock, TweenInfo.new(1.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Position = humRp.Position + Vector3.new(0,5,5)})
if DestroyTween == false then
tween2:Play()
else
tween2:Cancel()
end
if DestroyTween == true and Destroyed == true then
Render:Disconnect()
end
end)
end
elseif phase == '2' then
DestroyTween = true
Destroyed = true
TweenService:Create(Rock, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Position = workspace.anim.HumanoidRootPart.Position}):Play()
end
Rock.Destroying:Connect(function()
Destroyed = true
end)
end