-
What do you want to achieve? Tazer, when you get hit, you play an animation of being taxed, and you can’t move/jump and can’t equip items.
-
What is the issue? I can move and jump, and still equip items.
-
What solutions have you tried so far? I tried a different method, but it didn’t seem to work.
local Tool = script.Parent
local TaserEvent = Tool:WaitForChild("FireTaser")
local RemoveBackpack = game.ReplicatedStorage.RemoveBackpack
local TaserOrigin = Tool.TaserOriginPoint
local TaserLimit = 25
local PS = game:GetService("Players")
local TazeAnimation = script.Animation
TaserEvent.OnServerEvent:Connect(function(plr, MouseHit)
print((plr.Character.Torso.Position - MouseHit).Magnitude)
if (plr.Character.Torso.Position - MouseHit).Magnitude <= TaserLimit then
local rayInfo = RaycastParams.new()
rayInfo.FilterDescendantsInstances = {Tool:GetChildren()}
rayInfo.FilterType = Enum.RaycastFilterType.Blacklist
local rayOrigin = TaserOrigin.Position
local rayDirection = ((MouseHit - TaserOrigin.Position).Unit) * 100
local RaycastTaser = workspace:Raycast(rayOrigin, rayDirection, rayInfo)
if RaycastTaser and RaycastTaser.Instance then
local RaycastInstance = RaycastTaser.Instance
if RaycastInstance.Parent:FindFirstChild("Humanoid") then
local Character = RaycastInstance.Parent
local Player = PS:GetPlayerFromCharacter(Character)
local Humanoid = RaycastInstance.Parent:FindFirstChild("Humanoid")
local Center = (RaycastTaser.Position + TaserOrigin.Position) / 2
local TazerLine = Instance.new("Part")
TazerLine.Anchored = true
TazerLine.CanCollide = false
TazerLine.Material = Enum.Material.Neon
TazerLine.Parent = workspace
TazerLine.Size = Vector3.new(0.01, 0.01,(TaserOrigin.Position - MouseHit).Magnitude)
TazerLine.CFrame = CFrame.lookAt(Center, RaycastTaser.Position)
TazerLine.Color = Color3.fromRGB(18, 238, 212)
if Humanoid.Animator then
local Animator = Humanoid.Animator
local AnimTrack = Animator:LoadAnimation(TazeAnimation)
AnimTrack:Play()
Humanoid:UnequipTools()
RemoveBackpack:FireClient(Player)
wait(0.2)
TazerLine:Destroy()
wait(4)
AnimTrack:Stop()
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
print("Done")
end
end
end
else
local TazerLine = Instance.new("Part")
TazerLine.CanCollide = false
TazerLine.Anchored = true
TazerLine.Color = Color3.fromRGB(18, 238, 212)
TazerLine.Material = Enum.Material.Neon
TazerLine.Parent = workspace
local Center = (MouseHit + TaserOrigin.Position) / 2
TazerLine.Size = Vector3.new(0.01, 0.01, (TaserOrigin.Position - MouseHit).Magnitude)
TazerLine.CFrame = CFrame.lookAt(Center, MouseHit)
wait(0.05)
TazerLine:Destroy()
end
end)
I have a second local script within a remoteevent in replicated storage
local StartGui = game:GetService("StarterGui")
game.ReplicatedStorage.RemoveBackpack.OnClientEvent:Connect(function()
StartGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
wait(4.2)
StartGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, true)
end)
Everything works except this: Humanoid.WalkSpeed = 1 Humanoid.JumpPower = 50, and that specific script above. I also know the if statement works because the animation plays.
Any suggestions would be very helpful.
Also, no errors. It just continues on with the script.