Hello, I would like to make a local player touch a part and check if its Roles is in a his stringValue (I have already created or not)
how can I do this? I don’t know very well how to create this check
In short, as you see in the image it says “Roles” I want to create a check when a player touches a specific “Part” and if its ‘roles name’ is “Good” (for example) then it will print “You are good” of otherwise (else) will show a print “You are not good”.
I share my script, everything is working properly
I only need to obtain the Role Value of the player who touched the Part and do checks.
Example: if his Role == "RoleName" then print something
Any idea how to do it?
Could someone give me a hand, I would appreciate it very much.
Script:
local DataStoreService = game:GetService('DataStoreService')
local RanksDataStores = DataStoreService:GetDataStore('RanksDataStores')
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new('Folder', player)
leaderstats.Name = 'leaderstats'
local Ranks = Instance.new('StringValue', leaderstats)
Ranks.Name = 'Roles'
local RanksData
local success, errormessage = pcall(function()
RanksData = RanksDataStores:GetAsync('Ranks_'..player.UserId)
end)
if RanksData and success then
player.leaderstats.Roles.Value = RanksData
print("Data has been saved!")
else
warn(errormessage)
print("There is something wrong.")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local Ranks = player.leaderstats.Roles
local success, errormessage = pcall(function()
RanksDataStores:SetAsync("Ranks_" .. player.UserId, Ranks.Value)
end)
end)