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

Keycard dosen't change its value and i still can pick up lower level card how do i fix this?

So for the last week i am trying to make a keycard to my game

Keycard Code:

local GetServ = game:GetService("ServerScriptService")
local prox = script.Parent.ProximityPrompt
KeycardLvlP = game.Workspace.CardLevel.Value --the "CardLevel" is a NumberValue
KeycardLvlI = 5

script.parent.ProximityPrompt.Triggered:Connect(function()

	if KeycardLvlP < KeycardLvlI then
		KeycardLvlP = KeycardLvlI
		print("Player now has keycard level " ..KeycardLvlP.. "!")	
	else
		print("already has that card")
	end

end)

But it dosen't work when i try to pick up a card with less value it dosen't block and the CardLevel dosen't even change PLEASE HELP

There are 5 levels of a card

1 answer

Your getting a value without checking IF it's changed, to fix this just make it check the value BUT put the path to your value.

here's your fix:

local GetServ = game:GetService("ServerScriptService")
local prox = script.Parent.ProximityPrompt
KeycardLvlP = game.Workspace.CardLevel -- changed to the key level
KeycardLvlI = 5

script.parent.ProximityPrompt.Triggered:Connect(function()

    if KeycardLvlP.Value < KeycardLvlI then
        KeycardLvlP.Value = KeycardLvlI
        print("Player now has keycard level " .. KeycardLvlP.Value .. "!")  
    else
        print("already has that card")
    end

end)

3 comments

0

THANK YOU SO MUCH IT WORKED

0

Your welcome, but mark it as your answer so other developers / scripters don't waste time checking / answering your question.

0

Hey its me i lost password to the "anots66" acc and now cant mark it sorry

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