hi guys!
i am working on my lightsaber game but it has an issue
when i eqquip the lightsaber when the player is spawned it wont activate anything after requip
it will…
but i want to make it so it doesnt need a requip
example off what happends:
robloxapp-20230331-1652240.wmv (724.2 KB)
does somebody know how i might fix this?
Need help asap!..!
1 Like
Can you send the code, so that we can actually help you. As well the format is not letting me watch the video.
is it good if i send a yt video of it?
I will also need the code, to actually help.
1 Like
here is the yt video
here is the code
local block = script.Parent.Blocking.Blocking
local block1 = script.Parent.Blocking.Blocking1
local remoteEvent2 = script.Parent["Enable/Disable"].DisableSaber
local tool = script.Parent
local anim = Instance.new("Animation")
local anim1 = Instance.new("Animation")
local anim2 = Instance.new("Animation")
local anim3 = Instance.new("Animation")
local t = tool.Unequipped:Connect(function()
local plr = game.Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
local hold = false
anim.Name = "IdleAnim"
anim.AnimationId = "rbxassetid://12928388085" -- Idle Animaton ID
anim1.Name = "EquipAnim"
anim1.AnimationId = "rbxassetid://12952104477"-- Equip Tool Animaton ID
anim2.Name = "BlockAnim"
anim2.AnimationId = "rbxassetid://12779484367" -- block Animaton ID
anim3.Name = "UnBlock"
anim3.AnimationId = "rbxassetid://12952185854" -- block Animaton ID
local track
local track1
local track2
local track3
-- When Tool Equipped
tool.Equipped:Connect(function()
script.Parent.Equippedvalue.Value = true
print("equipped")
track = script.Parent.Parent.Humanoid:LoadAnimation(anim)
track1 = script.Parent.Parent.Humanoid:LoadAnimation(anim1)
track2 = script.Parent.Parent.Humanoid:LoadAnimation(anim2)
track3 = script.Parent.Parent.Humanoid:LoadAnimation(anim3)
track.Priority = Enum.AnimationPriority.Movement
track1.Priority = Enum.AnimationPriority.Movement
track2.Priority = Enum.AnimationPriority.Movement
track3.Priority = Enum.AnimationPriority.Movement
track.Looped = true
track1:Play()
track:Play()
script.Parent["Lightsaber ignite"].Enabled = true
script.Parent.serverignite.Enabled = true
script.Parent.serverSwoosh.Enabled = true
script.Parent.serverdisable.Enabled = true
end)
-- When Tool UnEquipped
tool.Unequipped:Connect(function()
script.Parent.LightsaberEnabled.Value = false
remoteEvent2:FireServer()
script.Parent.Attack1.Enabled = false
script.Parent.Attack2.Enabled = false
script.Parent.Attack3.Enabled = false
script.Parent.Attack4.Enabled = false
script.Parent["Lightsaber top"].Part.Outer.Enabled = false
script.Parent["Lightsaber top"].Part.Inner.Enabled = false
script.Parent.Equippedvalue.Value = false
script.Parent["Lightsaber ignite"].Enabled = false
script.Parent.serverignite.Enabled = false
script.Parent.serverSwoosh.Enabled = false
script.Parent.serverdisable.Enabled = false
script.Parent["lightsaber swoosh"].Enabled = false
script.Parent["Lightsaber Disable"].Enabled = false
script.Parent["Lightsaber ignite"].Ignite:Stop()
script.Parent.lightsaberonidle:Stop()
script.Parent["Lightsaber Disable"].Disable:Stop()
script.Parent["Lightsaber top"].Part1.Transparency = 1
script.Parent["Lightsaber top"].Part1.PointLight.Enabled = false
script.Parent["Lightsaber top"].Part1.ParticleEmitter.Enabled = false
script.Parent["Lightsaber top"].Part1.Trail.Enabled = false
script.Parent["Lightsaber top"].Part.Transparency = 1
script.Parent["Lightsaber top"].Part.PointLight.Enabled = false
script.Parent["Lightsaber top"].Part.Trail.Enabled = false
script.Parent["Lightsaber top"].Part.ParticleEmitter.Enabled = false
if track and track1 then
track:Stop()
track1:Stop()
track2:Stop()
end
end)
idk i added the print() to see when it activates but it only happends when its equipped for the second time
We need the code to help you! Please send it over if you’re still having this issue.
done!! (30 lettersssssssssss ))
Isn’t the Humanoid:LoadAnimation() deprecated? I think you’d wanna use the LoadAnimation on the animator inside the Humanoid instead.
well… i didnt know the Humanoid:LoadAnimation() was deprecated…
and now is the question (how am i suppose to do it now?)
i dont think it has anything to do with the animations cuz it Print() works after second equip
Well, you can be too sure with them animations.
But let me try to throw in my 2 cents.
Delete these 4 lines
track = script.Parent.Parent.Humanoid:LoadAnimation(anim)
track1 = script.Parent.Parent.Humanoid:LoadAnimation(anim1)
track2 = script.Parent.Parent.Humanoid:LoadAnimation(anim2)
track3 = script.Parent.Parent.Humanoid:LoadAnimation(anim3)
Replace with this and then move these lines to
local Animator = script.Parent.Parent.Humanoid.Animator
local track = Animator:LoadAnimation(anim)
local track1 = Animator:LoadAnimation(anim1)
local track2 = Animator:LoadAnimation(anim2)
local track3 = Animator:LoadAnimation(anim3)
to here and replace these with the new lines:
local track
local track1
local track2
local track3
That way the animation is already properly loaded onto the animator.
i fixed the issue myself it didnt have to do anything with the animations, they work properly
what i did wrong is this:
local block = script.Parent.Blocking.Blocking
local block1 = script.Parent.Blocking.Blocking1
local remoteEvent2 = script.Parent["Enable/Disable"].DisableSaber
local tool = script.Parent
local anim = Instance.new("Animation")
local anim1 = Instance.new("Animation")
local anim2 = Instance.new("Animation")
local anim3 = Instance.new("Animation")
**local t = tool.Unequipped:Connect(function()**
local plr = game.Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
local hold = false
anim.Name = "IdleAnim"
anim.AnimationId = "rbxassetid://12928388085" -- Idle Animaton ID
anim1.Name = "EquipAnim"
anim1.AnimationId = "rbxassetid://12952104477"-- Equip Tool Animaton ID
anim2.Name = "BlockAnim"
anim2.AnimationId = "rbxassetid://12779484367" -- block Animaton ID
anim3.Name = "UnBlock"
anim3.AnimationId = "rbxassetid://12952185854" -- block Animaton ID
local track
local track1
local track2
local track3
-- When Tool Equipped
tool.Equipped:Connect(function()
script.Parent.Equippedvalue.Value = true
print("equipped")
track = script.Parent.Parent.Humanoid:LoadAnimation(anim)
track1 = script.Parent.Parent.Humanoid:LoadAnimation(anim1)
track2 = script.Parent.Parent.Humanoid:LoadAnimation(anim2)
track3 = script.Parent.Parent.Humanoid:LoadAnimation(anim3)
track.Priority = Enum.AnimationPriority.Movement
track1.Priority = Enum.AnimationPriority.Movement
track2.Priority = Enum.AnimationPriority.Movement
track3.Priority = Enum.AnimationPriority.Movement
track.Looped = true
track1:Play()
track:Play()
script.Parent["Lightsaber ignite"].Enabled = true
script.Parent.serverignite.Enabled = true
script.Parent.serverSwoosh.Enabled = true
script.Parent.serverdisable.Enabled = true
end)
-- When Tool UnEquipped
tool.Unequipped:Connect(function()
script.Parent.LightsaberEnabled.Value = false
remoteEvent2:FireServer()
script.Parent.Attack1.Enabled = false
script.Parent.Attack2.Enabled = false
script.Parent.Attack3.Enabled = false
script.Parent.Attack4.Enabled = false
script.Parent["Lightsaber top"].Part.Outer.Enabled = false
script.Parent["Lightsaber top"].Part.Inner.Enabled = false
script.Parent.Equippedvalue.Value = false
script.Parent["Lightsaber ignite"].Enabled = false
script.Parent.serverignite.Enabled = false
script.Parent.serverSwoosh.Enabled = false
script.Parent.serverdisable.Enabled = false
script.Parent["lightsaber swoosh"].Enabled = false
script.Parent["Lightsaber Disable"].Enabled = false
script.Parent["Lightsaber ignite"].Ignite:Stop()
script.Parent.lightsaberonidle:Stop()
script.Parent["Lightsaber Disable"].Disable:Stop()
script.Parent["Lightsaber top"].Part1.Transparency = 1
script.Parent["Lightsaber top"].Part1.PointLight.Enabled = false
script.Parent["Lightsaber top"].Part1.ParticleEmitter.Enabled = false
script.Parent["Lightsaber top"].Part1.Trail.Enabled = false
script.Parent["Lightsaber top"].Part.Transparency = 1
script.Parent["Lightsaber top"].Part.PointLight.Enabled = false
script.Parent["Lightsaber top"].Part.Trail.Enabled = false
script.Parent["Lightsaber top"].Part.ParticleEmitter.Enabled = false
if track and track1 then
track:Stop()
track1:Stop()
track2:Stop()
end
end)
local t = tool.Unequipped:Connect(function()
this seemed to cause problems but i figured it out, thanks for helping anyways :D!!!
1 Like
I’m sorry but this is a very redundant script, you ned to revamp it for readability.
2 Likes
its not causing lag wich is great so i think ama stick to this…
system
(system)
Closed
April 16, 2023, 8:26pm
#14
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.