Im a beginner to scripting and I need help accessing a value i put in starterplayerscripts
The places marked with “— boolean value” are where i need to access the player.
Heres my code:
local DS = game:GetService('DataStoreService')
local elbow = DS:GetDataStore("elbow")
local players = game:GetService('Players')
---Elbow_Smash---
local Part = script.Parent.Parent
local ProximityPrompt = game.Workspace.Tool.ProxPart.ProximityPrompt
ProximityPrompt.Triggered:connect(function(Player)
if Player and Player.Character then
Player.leaderstats.Points.Value = Player.leaderstats.Points.Value - 1000
game.Players:FindFirstChild(Player).PlayerScripts.Abilities.elbow_smash.Value = true — boolean value
wait(1)
local success, errorMessage = pcall(function()
elbow:SetAsync(Player.UserId.."elbow", game.Players:FindFirstChild(Player).PlayerScripts.Abilities.elbow_smash.Value) --boolean value
end)
if success then
print("elbow_Smash saved")
else
warn(errorMessage)
print("data not saved yuh oh")
end
end
end)
local data
game.Players.PlayerAdded:Connect(function(player)
local success, errorMessage = pcall(function()
data = elbow:GetAsync(player.UserId.."elbow")
end)
if success then
player.PlayerScripts.Abilities.elbow_smash.Value = data — Boolean value
print("importing data for:".. player.UserId)
else
print("import failed")
warn(errorMessage)
end
end)
--Elbow Smash--
I don’t understand why you are trying to use game.Players:FindFirstChild(Player) where Player is already the player in question? I think you are sort of mixing up the thinking about what the player is.
i tried Player.PlayerScripts but it didnt work so i started trying other methods in getting them and the :findfirstchild(Player) happened to be the last method i tried. The reason i did that was because i ran a test and printed out Player and it printed my username so i thought i could use :findfirstchild(Player) to get the player.
player is an instance and print found the name and just outputted that but I believe findfirstchild doesn’t convert it into a string so you’d need to do player.name if you want to use findfirstchild
Are you suggesting i create a variable for the data? Also the script is in a proximity prompt. Im gonna try creating a bool value in serverscriptservice with players name on it.