I am working on a system for a redo of one of my games, where NPCs act as “droppers” where they hit a punching bag, and the owner gets cash.
It’s going well, until I tried adding a particle effect to the hand of the NPC, that would get enabled when the hand hits the punching bag for an effect. In the below video, you can see the effect either does not get enabled, or, if it does, it plays way after the NPC has had the bag already.
How do I fix this?
Below are the values for the particle:
Here is the code for the system (so far):
local hum = script.Parent.Humanoid
local aID = script.Parent:GetAttribute("id")
local animation = hum.Parent:FindFirstChild("animation") or Instance.new("Animation",hum.Parent)
animation.AnimationId = "rbxassetid://"..aID
local animator = hum:FindFirstChildOfClass("Animator") or Instance.new("Animator",hum)
local animationTrack = animator:LoadAnimation(animation)
local goal = {}
goal.StudsOffsetWorldSpace = Vector3.new(0,3,0)
local ts = game:GetService("TweenService")
local info = TweenInfo.new(1.5, Enum.EasingStyle.Quart)
script.Parent.RightHand.Touched:Connect(function(otherPart: BasePart)
if otherPart.BrickColor == BrickColor.new("Dusty Rose") then
script.Parent.RightHand.RightGripAttachment.punch.Enabled = true
end
end)
while wait(1) do
local gui = script.earnings:Clone()
animationTrack:Play()
gui.Parent = script.Parent.Head
gui.Adornee = script.Parent.Head
gui.Enabled = true
local success, response = pcall(function()
local tweenGUI = ts:Create(gui, info, goal)
tweenGUI:Play()
tweenGUI.Completed:Wait()
end)
if success then
print("hi")
else
print(response)
end
script.Parent.RightHand.RightGripAttachment.punch.Enabled = false
gui:Destroy()
end
The code is messy, I know, but this is early development and I just need to get a working prototype working