Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how should i access a player folder to change the players value?

i'm asking this question again but basically you push a ball and the ball falls and respawns, during the fall it hits a part which executes a script that respawns the ball, but i also want the script to increase the "wins" value

part script:

function onTouched(hit)
	if hit.Name == "Ball" then
	game.workspace.Ball:Destroy()
	local newball = Instance.new("Part", workspace)
	local face = Instance.new("Decal", newball)
	local actualface = "rbxassetid://34067417"
	newball.Shape = Enum.PartType.Ball
	newball.Size = Vector3.new(4,4,4)
	newball.Position = Vector3.new(-25.255, 4.889, 25.769)
	newball.Name = "Ball"
	newball.TopSurface = Enum.SurfaceType.Smooth
	newball.BottomSurface = Enum.SurfaceType.Smooth
	newball.Anchored = false
	face.Texture = actualface
	face.Face = Enum.NormalId.Back
	end
end
script.Parent.Touched:Connect(onTouched)

leaderboard script if anyones interested:

local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("winsaves")

game.Players.PlayerAdded:connect(function(plr)
	local folder = Instance.new("Folder", plr)
	folder.Name = 'leaderstats'
	local wins = Instance.new("IntValue", folder)
	wins.Name = 'wins'
-- deaths which aren't useful here so i got rid of them
	wins.Value = ds1:GetAsync(plr.UserId)
	ds1:SetAsync(plr.UserId, wins.Value)
	
	wins.Changed:connect(function(plr)
		ds1:SetAsync(plr.UserId, wins.Value)
	end)
end)

1 answer

Try to add this to Part Script

local player = game.Players:GetPlayerFromCharacter(hit.Parent)
player.leaderstats.wins.Value = player.leaderstats.wins.Value + 1

This discussion is preserved as it was. New answers, comments, and votes are closed.