Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make my Tool a collectible item?

Asked by 5 years ago

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

0
Are any children of the tool non-archive-able or being destroyed? N43FGXL 169 — 5y
0
i'm destroying the script at the end yes, but for the non-archive-able i will quickly check aprilsfooled 29 — 5y
0
all parts are checked 'archivable' aprilsfooled 29 — 5y
0
Ok I answered it. N43FGXL 169 — 5y
0
thanks, that did solve the not valid member part, however the tool itself is still not being loaded in the game? aprilsfooled 29 — 5y

1 answer

Log in to vote
0
Answered by
N43FGXL 169
5 years ago
Edited 5 years ago

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.

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. N43FGXL 169 — 5y
Ad

Answer this question