- What do you want to achieve?
I want to be able to access a player’s data when they join the game.
- What is the issue?
No issue
- What solutions have you tried so far?
I did as much as I can researching API on the dev forums
--Local Script
local frame = script.Parent.Parent.userInterface.badgeFrame
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local inFrame = false
local shadow = Instance.new("TextLabel")
local shadow = Instance.new("TextLabel", script.Parent.Parent.userInterface.badgeFrame)
shadow.Size = UDim2.new(0,50,0,50)
shadow.Text = ""
shadow.BackgroundColor3 = Color3.new(0, 0.666667, 1)
shadow.AnchorPoint = Vector2.new(.5,.5)
shadow.Visible = false
local blueBadgeData = {}
frame.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
local absPos = frame.AbsolutePosition
local badge = Instance.new("TextLabel", script.Parent.Parent.userInterface.badgeFrame)
badge.Size = UDim2.new(0,50,0,50)
badge.Text = ""
badge.BackgroundColor3 = Color3.new(0, 0.666667, 1)
badge.AnchorPoint = Vector2.new(.5,.5)
badge.Position = UDim2.new(0,mouse.X-absPos.X,0,mouse.Y-absPos.Y)
print(badge.Position)
table.insert(blueBadgeData,1,badge.Position)
game.ReplicatedStorage:WaitForChild("badgeStorageEvents"):WaitForChild("blueBadge"):FireServer(badge.AbsolutePosition.X, badge.AbsolutePosition.Y)
end
end)
frame.MouseEnter:Connect(function()
inFrame = true
shadow.Visible=true
while wait() do
local absPos = frame.AbsolutePosition
shadow.Position = UDim2.new(0,mouse.X-absPos.X,0,mouse.Y-absPos.Y)
if inFrame == false then
break
end
end
end)
frame.MouseLeave:Connect(function()
inFrame = false
shadow.Visible=false
end)
--Server Recieving Script
local repStorage = game:WaitForChild("ReplicatedStorage")
local blueBadgeEvent = repStorage.badgeStorageEvents:WaitForChild("blueBadge")
local dataStoreService = game:GetService("DataStoreService")
local badgeStorage = dataStoreService:GetDataStore("badgeStorage")
blueBadgeEvent.OnServerEvent:connect(function(player,x, y)
local id = player.UserId
local setsuccess, iserror = pcall(function()
badgeStorage:SetAsync(id, x)
badgeStorage:SetAsync(id, y)
end)
if not setsuccess then
warn(iserror)
end
local getSuccess, data = pcall(function()
return badgeStorage:GetAsync(id)
end)
if getSuccess then
end
end)
game.Players.PlayerAdded:Connect(function(player)
local id=player.UserId
local storage = badgeStorage:GetAsync(id)
print(storage)
end)