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

Checking rap in a datastore to enter an area?

What i am trying to do: I am trying to make it where if you touch a brick, and you have over 1b rap(in game), you will get teleported to an area.

The rap is stored in a datastore, and i combined a couple scripts to try to make this work.


local LocalPlayer = game.Players.LocalPlayer 
local data = {};
local dataStore = game:GetService("DataStoreService");
local sortedRAP = dataStore:GetOrderedDataStore("AveragePricee");
local playerData = data[LocalPlayer.UserId];
local assets = playerData and playerData.Assets;
local statistics = assets and playerData.Statistics;
local rap = sortedRAP:GetAsync(LocalPlayer.UserId, statistics.AveragePrice)
local rapneeded = 1,000,000,000

local metaData = {};
metaData.__index = metaData;

function metaData:getSortedDataStore()
	return sortedRAP;
end

if rap >= rapneeded then
 place = CFrame.new(-17.342, 47.625, -43.636)
script.Parent.Touched:connect(function(p)
local humanoid = p.Parent:findFirstChild("Humanoid")
if (humanoid ~= nil) then 
humanoid.Torso.CFrame = place 
end
end)
end

Any help is appreciated.

3 comments

0

Use codeblock please!

0

Wow, terrible way to use datastores and cash and stuff.

0

I'm not creating a datastore, but trying to get a value of a players cash from the datastore i already have.

1 answer

--THIS IS A LOCAL SCRIPT
local DataStoreService = game:GetService("DataStoreService")
local Data = DataStoreService:GetDataStore("cashh")
local Munahy= Data:GetAsync(LocalPlayer.UserId)
local Cashneeded = --Cash needed

if Munahy >= Cashneeded then
--What ever you want here
end


So, you didn't give alot of information, so this is just a template for you. IDK what key you are using for the datastores, so i just assumed you are using player id's. Also, i put that the data store was "cashh". Was that a typo? anyways

This simple script will do code if your money is greater than the required amount. IDK how you are going to integrate it, so i just gave this basic snippet of code.

BTW i highly dont recommend using can collide for these kinds of things.

  1. in your script, you turn can collide of for everyone, so basically anyone can walk in if one person has the 1B.

  2. Use Collision groups, or just teleport the player inside.

2 comments

0

Localscripts cannot access datastores for security reasons.

0

Ok so i changed it to a script, and changeg it to where it teleports you inside. It isn't working.

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