Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make my Tool a collectible item?

Hello,

I've been struggling with this issue for a few days now... I made a tool, a potion that heals some of the player's damage when used. It works properly when placed in the starterpack, but errors (with the exact same script) when placed in the workspace (as I would like it to be a pickup tool and not a permanent item in the starterpack) But, the tool doesn't even show in the game and the script breaks on line3 (character = player.Character) saying "Character is not a valid member of DataModel. I've asked around but I can't seem to get a concrete answer. What am I missing/doing wrong?

local CanActivate = true local player = script.Parent.Parent.Parent or game.Players:GetPlayerFromCharacter(script.Parent.Parent) local character = player.Character

script.Parent.Activated:Connect(function() if CanActivate == true then CanActivate = false local animation = character.Humanoid:LoadAnimation(script.Parent.Animation) animation:Play() character.Humanoid.Health = character.Humanoid.Health + 25 print ("Health was restored by 25") wait(3) CanActivate = true script.Parent:Destroy() end end)

http://prntscr.com/ppfgrc

5 comments

0

Are any children of the tool non-archive-able or being destroyed?

0

i'm destroying the script at the end yes, but for the non-archive-able i will quickly check

0

all parts are checked 'archivable'

0

Ok I answered it.

0

thanks, that did solve the not valid member part, however the tool itself is still not being loaded in the game?

1 answer

✓ Accepted answer

First Error Your error occurs in line 3. When you get the error: "Character is not a valid member of DataModel" it means that 'Character' can't be displayed/used in the data model you are doing/using.

Change line 3 to this:

--
--
local character = player.Name --- use .Name instead of .Character!

You can't use character as the value for a string; character isn't a string.

I hope I helped you.

http://prntscr.com/ppfmwa

Second Error

Your other error is that you define player as script.Parent.Parent.Parent. If the tool is in the Workspace, the player will NOT be script.Parent.Parent.Parent. You may need to do some if statements or :WaitForChild()s.

You need to locate the player and make sure script.Parent.Parent.Parent IS a player instance.

1 comment

0

Your other error is that you define player as script.Parent.Parent.Parent. If the tool is in the Workspace, the player will NOT be script.Parent.Parent.Parent. You may need to do some if statements or :WaitForChild()s.

This discussion is preserved as it was. New answers, comments, and votes are closed.