How do I make my Script work on this Rig?

I’d like a dummy in-game to be able to swing a sword (for testing purposes)

I have a sword script for the players, I’ve done what I thought I needed to do to convert it to a dummy script that will work without a player, however, when I play, nothing happens to the dummy, no animations or anything.

Here’s my script for the dummy:

local rs = game:GetService("ReplicatedStorage")

local _M1 = rs.ClientModules.M1
local shootRays = rs.Remotes.ShootRays

local char = script.Parent

local swingCount = 1
local dmg = 20

local swingAnims = {
	rs.Anims.Swing1,
	rs.Anims.Swing2,
	rs.Anims.Swing3,
	rs.Anims.Swing4,
	rs.Anims.Swing5,
}

while true do
	local isFinal = false
	if swingCount < 5 then
		swingCount += 1
	else
		swingCount = 1
		isFinal = true
	end

	local humanoid = char:FindFirstChild("Humanoid")
	local animator = humanoid.Animator
	local swingAnimTrack = animator:LoadAnimation(swingAnims[swingCount])
	swingAnimTrack:Play()

	repeat wait() until swingAnimTrack.length > 0

	delay(swingAnimTrack.length/2.5, function()
		shootRays:FireServer(swingAnimTrack.length-swingAnimTrack.length/3.5, char, dmg)
	end)

	delay(swingAnimTrack.length-0.125, function()
		swingAnimTrack:AdjustSpeed(0.5)
	end)
	
	
	local cooldownTime = swingAnimTrack.length-0.15
	task.wait(cooldownTime)
end

p.s. It’s a local script.

2 Likes

Local scripts only work when they’re in specific places. Like PlayerScripts, PlayerGui, Under their character, ReplicatedFirst. So if you want this to work, you’d either convert it to a server script or give your player network ownership over the dummy and have your local script in one of those places a local script will run.

That worked great, just made it a server script, thanks so much!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.