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)
