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

Check if player already has item. Any help?

Asked by 9 years ago

In this script, its connected to my datastore. This script is a local script inside the player's backpack. If the saved value of the weapon =1 or > then it gives them the weapon. However, if a player buys this in game, I dont want them having 2 of them. I want it to check and see if the player has this item in there startergear, and if they do it will destroy the script. But if it doesnt it will move along and continue the script.

Here is the script:

wait(10)
local player = game.Players.LocalPlayer
    local playerChar = player.Character --Just incase I needed it :p
if player.Tools.HighJump.Value == 0 then
    script:Destroy()

elseif player.Tools.HighJump.Value >= 1  then
    print'Player Has HighJump'
    game.Lighting.HighJump:clone().Parent = player.StarterGear
    game.Lighting.HighJump:clone().Parent = player.Backpack
end

EDIT INFO: The reason it is player.Tools.HighJump is because the 'Tools' is a model inside the player. And the 'HighJump' Is an int value. If this int value is saved as 1 from my data store, then the player will receive the ability they purchased. If the int value is 0 then that means they have not purchased it.

1 answer

Log in to vote
0
Answered by 9 years ago

Just add this before your first if statment if player.StarterGear.Highjump =~ nil then script:Destroy

Also in this line of code if player.Tools.HighJump.Value == 0 then did you make it so tools is something inside of player? Normally players only have Backpack Startergear and Playergui from my testing.

0
its a data store thing i will explain it in a second, (Ill edit it so you understand) CarterTheHippo 120 — 9y
0
btw you have the =~ backwards its suppose to be ~= CarterTheHippo 120 — 9y
0
Sorry about that. Crystalsweeper 25 — 9y
Ad

Answer this question