Tazer is not making Backpack invisible and players can still move

  1. 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.

  2. What is the issue? I can move and jump, and still equip items.

  3. 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.

it should be

StartGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)

and the false should be

StartGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

But that’s what I have written down? Do you mean something else?

in the local script, you are doing playerlist instead of backpack.

1 Like

Thank you for the first half of the solution. Can’t believe I did that. Smh.

Also, before you play the animation try

Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0

So that works, but the backpack doesn’t work.
I edited the code to make it print, but it doesn’t print. I checked my variable, and it is correct. So I don’t know what to do.

local StartGui = game:GetService("StarterGui")

script.Parent.OnClientEvent:Connect(function()
	print("FALSE")
	StartGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
	wait(4.2)
	StartGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
end)

try moving the lines I said to make outside of the if statement and see if that works.

Doesn’t seem to work, or print.

I printed the player name, and it seems to be correct, so I have no clue why it wouldn’t be working.