Forget it (Close Topic)

I have a knife that was made for R6, and attempted to re-animate it and re-script it for R15. Here’s the code:

sp = script.Parent

r = game:service("RunService")
debris = game:GetService("Debris")

anims = {"OverHeadSwing","LeftSwingFast","RightSwingFast"}

Sounds = {{145180512, "Metal"}, {145180522, "Metal"}, {145180533, "Wood"}, {145180541, "Wood"}, {145180529, "Slash"}, {145180550, "Slash"}}

WoodSounds = {}
MetalSounds = {}
SlashSounds = {}

basedamage = 0
slashdamage = 690
swingdamage = 800
damage = basedamage

sword = sp.Handle
sp.Taunting.Value = false

local UnsheathSound = Instance.new("Sound")
UnsheathSound.SoundId = "http://www.roblox.com/Asset/?id=145180523"
UnsheathSound.Parent = sword
UnsheathSound.Volume = 0.5

for _,Sound in pairs(Sounds) do
	local S = Instance.new("Sound")
	S.SoundId = "http://www.roblox.com/Asset/?id=" .. Sound[1]
	S.Parent = sword
	S.Volume = 1
	if Sound[2] == "Wood" then
		table.insert(WoodSounds, S)
	elseif Sound[2] == "Metal" then
		table.insert(MetalSounds, S)
	elseif Sound[2] == "Slash" then
		table.insert(SlashSounds, S)
	end
end

function waitfor(parent,name)
	while true do
		local child = parent:FindFirstChild(name)
		if child ~= nil then
			return child
		end
		wait()
	end
end

waitfor(sp,"Taunting")
waitfor(sp,"RunAnim")
local Halt = false;
function blow(hit)
	if hit:findFirstChild("IsShield") then
		damage = 12
		pcall(function()
			if hit.IsShield.Value == "Wood" then
				WoodSounds[math.random(#WoodSounds)]:Play()
			elseif hit.IsShield.Value == "Metal" then
				MetalSounds[math.random(#MetalSounds)]:Play()
			else
				WoodSounds[math.random(#WoodSounds)]:Play()
			end
		end);
		return
	end
	if Halt then return end;
	Halt = true;
	if hit.Parent ~= nil then
		local humanoid = hit.Parent:findFirstChildOfClass("Humanoid")
		local vCharacter = sp.Parent
		if vCharacter ~= nil then
			local vPlayer = game.Players:playerFromCharacter(vCharacter)
			if vPlayer ~= nil then
				local hum = vCharacter:findFirstChild("Humanoid")
				if humanoid ~= nil then
					if hum ~= nil and humanoid ~= hum then
						local right_arm = vCharacter:FindFirstChild("RightHand")
						if right_arm ~= nil then
							local joint = right_arm:FindFirstChild("RightGripAttachment")
							if joint ~= nil and (joint.Part0 == sword or joint.Part1 == sword) then
								tagHumanoid(humanoid,vPlayer)
								humanoid:TakeDamage(damage)
								script.Parent.Handle.Hit:Play()
								wait(.3)
							end
						end
					end
				end
			end
		end
	end
	Halt = false;
end

function tagHumanoid(humanoid,player)
	for i,v in ipairs(humanoid:GetChildren()) do
		if v.Name == "creator" then
			v:Destroy()
		end
	end
	local creator_tag = Instance.new("ObjectValue")
	creator_tag.Value = player
	creator_tag.Name = "creator"
	creator_tag.Parent = humanoid
	debris:AddItem(creator_tag,1)
end

sp.Enabled = true
function onActivated()
	if sp.Enabled and not sp.Taunting.Value then
		sp.Enabled = false
		local character = sp.Parent;
		local humanoid = character.Humanoid
		if humanoid == nil then
			print("Humanoid not found")
			return 
		end
		SlashSounds[math.random(#SlashSounds)]:Play()
		sp.Handle.Trail.Enabled = true
		newanim = anims[math.random(1,#anims)]
		while newanim == sp.RunAnim.Value do
			newanim = anims[math.random(1,#anims)]
		end
		sp.RunAnim.Value = newanim
		if newanim == "OverHeadSwing" then
			damage = swingdamage
		else
			damage = slashdamage
		end
		wait(.3)
		sp.Handle.Trail.Enabled = false
		damage = basedamage
		sp.Enabled = true
	end
end

function onEquipped()
script.Parent.Handle["Unsheath:Play()"]:Play()
end

sp.Activated:connect(onActivated)
sp.Equipped:connect(onEquipped)

connection = sword.Touched:connect(blow)

But the animations don’t play when I click. And I CONVERTED them into R15, and I have the valid animations, and yet they won’t work.

when your playing an animation in this line of your script

script.Parent.Handle.Hit:Play()
--it should be done like this
local animation = humanoid:LoadAnimation(script.Parent.Handle.Hit)
animation:Play()
animation.Stopped:Wait()--you can add this line to wait until the animation is finished playing

It’s supposed to be a random animation of the following: OverheadSwing, LeftSwingFast, and RightSwingFast. If the following picture of code works with R6, it’s gotta work with R15.image

nowhere in that script is the animation actually loaded and played

to load and play animations you have to do what i said from the looks of that code it seems like that function just handle sound playing,damage and adding trails

image Right here, it loads a random animation.

are you sure that all the code

no its just selecting one there

Please watch your post bumping. (Posting over and over without keeping all of the words you say in one post.) Anyway, this is the “animation” part of the code.

function onActivated()
	if sp.Enabled and not sp.Taunting.Value then
		sp.Enabled = false
		local character = sp.Parent;
		local humanoid = character.Humanoid
		if humanoid == nil then
			print("Humanoid not found")
			return 
		end
		SlashSounds[math.random(#SlashSounds)]:Play()
		sp.Handle.Trail.Enabled = true
		local		newanim = anims[math.random(1,#anims)]
		while newanim == sp.RunAnim.Value do
			newanim = anims[math.random(1,#anims)]
		end
		sp.RunAnim.Value = newanim
		if newanim == "OverHeadSwing" then
			damage = swingdamage
		else
			damage = slashdamage
		end
		wait(.3)
		sp.Handle.Trail.Enabled = false
		damage = basedamage
		sp.Enabled = true
	end
end

by load i mean this

--if your using that script you would do:
local animation = humanoid:LoadAnimation(newAnim)
animation:Play()

Are you sure there is not a function connected to sp that detects a change in value

--in this line
sp.RunAnim.Value = newanim
--check if there is anywhere in the code that has this:
sp.Changed:Connect(function()

end
--[[
anyways i have told you how  to load and play animations
and i'm sure i am correct i have many animations in a project
im working on and thats how you do it.]]--

I don’t know. Check the code posted way above.

I did and I am telling you no actual animation is being played can you atleast try what i said to do.

If you are just going to reject people’s suggestions without trying, don’t post. This thread already lacks enough information as it is. Please read the category guidelines for more information and details on what should be included in a help request.

Dumping an entire script here, especially if it isn’t yours, and saying it doesn’t work isn’t sufficient enough for a thread in this category.

1 Like

Flag your own post under “Something Else” and ask for it to be deleted, or update your thread with actual information to work off of. Such can include (but is not limited to):

  • Console errors
  • Code hierarchy
  • Animation setup
  • Owner info (where its being uploaded and/or used at)

Please also use the reply button on a post rather than at the bottom. People can’t see when you reply so they don’t get notifications and have to constantly come back to see if there’s a reply to what they said or not.

It at least says this in the Output.image

Unflag it. He’s right in what he says.

Interpret this as a literal error. The object RunAnim isn’t a descendant of StringValue (whatever StringValue is). This is something that can be resolved if you put some time into debugging your code. Please address code issues what you can by yourself first before posting a thread.

It’d be worth investing into the concepts of writing in (Roblox) Lua to help you with this in the future.

1 Like

I can’t invest in concepts like that, unfortunately.

that saying you tried to index something thats not a property of a string value, try clicking on that error to go to line in the script with that error