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.
--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.
in your script, you turn can collide of for everyone, so basically anyone can walk in if one person has the 1B.
Use Collision groups, or just teleport the player inside.