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

Check if player already has item. Any help?

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

✓ Accepted answer

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.

3 comments

0

its a data store thing i will explain it in a second, (Ill edit it so you understand)

0

btw you have the =~ backwards its suppose to be ~=

0

Sorry about that.

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