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

Checking rap in a datastore to enter an area?

Asked by 6 years ago
Edited 6 years ago

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.

0
Use codeblock please! R_alatch 394 — 6y
0
Wow, terrible way to use datastores and cash and stuff. hiimgoodpack 2009 — 6y
0
I'm not creating a datastore, but trying to get a value of a players cash from the datastore i already have. Brydell 0 — 6y

1 answer

Log in to vote
-1
Answered by 6 years ago
--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.

0
Localscripts cannot access datastores for security reasons. hiimgoodpack 2009 — 6y
0
Ok so i changed it to a script, and changeg it to where it teleports you inside. It isn't working. Brydell 0 — 6y
Ad

Answer this question