GetAttribute not working

Hi! So this is probably a dumb question, but for some reason this code is not detecting when an attribute is a certain thing. I have already checked while the game was running and Roblox studio said the attribute is “Knife” but it is not printing it or doing 10 damage. am I using GetAttribute wrong?

		if script:GetAttribute("Weapon") == "Knife" then
			damage = 10
			damage = 5

I will show more code if you want, but I am pretty sure this part of the code is the issue.

What exactly are you trying to do? You’re only setting the variable “damage” – not having it do anything.

Can you show us your full code? Also, why are you getting the attribute of a script? Surely you’d much rather use attributes for other objects, no?

1 Like

A script which sees what you are holding sends the weapon name to this and this script tells you how much damage it does. I have figured out a better method but I still can’t get it to get the attribute.

NEVERMIND I was replying to you guys and realized it was because I have a localscript trying to send an attribute to a server script. I am dumb sorry for wasting your time.

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