i am trying to increase a value after a ball falls down into the abyss and dissapears (while hitting a invisible part)
the script is inside the invisible part that the ball hits, and it executes the same script everytime a ball hits it
function onTouched(hit)
game:GetService("DataStoreService"):GetOrderedDataStore("winsaves")
local wins = game:GetService("Players"):FindFirstChild("Folder")
wins.Value = wins.Value + 1
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
newball.Parent = game.workspace.epic
face.Texture = actualface
face.Face = Enum.NormalId.Back
end
end
script.Parent.Touched:Connect(onTouched)

3 comments
you seem to have done it at line 4 and why are you making a new ball?
I thought you where deleting a ball?
the ball has to respawn so the player can redo the objective