Need help with point system

Hello, today I was making a game, and stumbed upon a complication. I don’t really know how to script, but this is the place where I can ask you all for advice and help.

So basically, what I am seeking is some help with making a point system. Ill explain in further detail.

This is my current point system script.

game.Players.PlayerAdded:Connect(function(plr)
	
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = plr
	
	
	local bux = Instance.new("NumberValue")
	bux.Name = "BallBux"
	bux.Parent = leaderstats
	
	
end)

I need a script that can register when a ball hits one of the boxes in the bottom of the plinko chamber.

A ball = 1 Point when It’s dropped.
Multi = Multiplier

When a 1 point ball hits one of the boxes it gives the points as the multiplier the box is.
So if a 1 point ball hits 0.2x = It adds 0.2 points to the point system
If it hits 1000x = The 1 point ball gives 1000 points.
You get the point.

So basically what I need is when a ball hits a box, It adds the multiplier of the box to the point system.

A ball is dropped with this script

local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(Key) -- input detected
	if Key.KeyCode == Enum.KeyCode.Space or Key.KeyCode == Enum.KeyCode.Return  
	then
		local sphere = Instance.new("Part")
		sphere.Size = Vector3.new(1.1,1.1,1.1) 
		sphere.Shape = Enum.PartType.Ball
		sphere.Color = Color3.new(0.803922, 0.329412, 0.294118)
		sphere.Position = Vector3.new(-9.486, 37.43, 19.383) 
		sphere.Anchored = false
		sphere.CanCollide = true
		sphere.Parent = workspace
	end
end)

UserInputService.InputEnded:Connect(function()
	print("The Part Has Successfully Been Dropped")
end)
1 Like

This has very similar logic to most Tycoon game where your part hits multiplier machines and its value increased. You can set Touched() on the multiplier part, to check if there is a part that goes through it, and then you can multiply the value from there. Here is some example code for you to get started with.

local multiplierPart = workspace.multiplierPart

multiplierPart.Touched:Connect(function(otherPart)
      if otherPart.Name == "Ball" then
             otherPart:SetAttribute("RealValue", otherPart:GetAttribute("RealValue") * multiplierPart:GetAttribute("MultiplierWhenTouched"))
      end
end)

This is only an example code, it may not work perfectly, but at least it should give you an idea on how to implement one.

1 Like

This might be all UI so .Touched() wouldn’t work but just to confirm @Aymoc is this a UI or an actual part in the workspace?

This is an actual model in-game, tough I wanted to try out with UI engine (NatureV2) but I didn’t really get anywhere with it.

I feel like using UI is not a correct approach. It might, but it will be a pain, since there is no physics engine being created using purely UI. Dropping ball logic will be a real pain. If you want to to that, Camera manipulation can be used to pretending as the plinko is playing 2D. Or try using Nature2D - 2D Physics Engine for UI Elements (NatureV2) for simulating physics engine in 2D space.

And you mentioned it, I didn’t see it. And yep, that might be where you want to look more into.

Great, I know this is kind of off topic but do you know how i can make a 0.5 second cooldown on this script?

local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(Key) -- input detected
	if Key.KeyCode == Enum.KeyCode.Space or Key.KeyCode == Enum.KeyCode.Return  
	then
		local sphere = Instance.new("Part")
		sphere.Size = Vector3.new(1.1,1.1,1.1) 
		sphere.Shape = Enum.PartType.Ball
		sphere.Color = Color3.new(0.803922, 0.329412, 0.294118)
		sphere.Position = Vector3.new(-9.486, 37.43, 19.383) 
		sphere.Anchored = false
		sphere.CanCollide = true
		sphere.Parent = workspace
	end
end)

UserInputService.InputEnded:Connect(function()
	print("The Part Has Successfully Been Dropped")
end)

Where does this script go in and where can I change the multiplier?

Yes of course, you can setup a new boolean outside the function, indicating that the ball can be dropped. If yes, you drop the ball, the that boolean to false, and then create a new thread that will reset the value after x seconds like this

local UserInputService = game:GetService(“UserInputService”)

local canDropBall = true
local cooldownTimer = 0.5

UserInputService.InputBegan:Connect(function(Key) -- input detected
	if Key.KeyCode == Enum.KeyCode.Space or Key.KeyCode == Enum.KeyCode.Return  
	then
        if canDropBall = true then
           canDropBall = false
           local sphere = Instance.new("Part")
		   sphere.Size = Vector3.new(1.1,1.1,1.1) 
		   sphere.Shape = Enum.PartType.Ball
		   sphere.Color = Color3.new(0.803922, 0.329412, 0.294118)
		   sphere.Position = Vector3.new(-9.486, 37.43, 19.383) 
		   sphere.Anchored = false
		   sphere.CanCollide = true
		   sphere.Parent = workspace
        end
		
	end
end)

UserInputService.InputEnded:Connect(function()
	print("The Part Has Successfully Been Dropped")
    print("Reset cooldown")
    delay(cooldownTimer,function()
            canDropBall = true
    end)
end)

UserInputService works best inside LocalScript. You can use it with RemoteEvent if you want to send something to the server.

Where do I put the multiplier script?

Multiplier script can be put inside server script and let the server handle how it should works.

Can’t I just make the top variable script.parent if the script sits inside the multiplierbox

Or does that decrease performance and make the load heavier for the server?

Of course you can! About the performance, please check it using Script Performance inside Roblox Studio to see if it is resource consuming.

Alright, you anwsered a bunch of important steps.

But I still need help with the points.
How do I make the script add the multiplier of the points, to the point system, and how do I make it subtract 1 point every ball dropped?

Use the code as put earlier as a guide on how to implement the multiplier. For subtraction, you can tracking value inside the IntValue, and subtract it every time you drop the ball.

But I don’t have any values yet how do I make it work all with eachother?

I genuinely would want to answer all your questions. But I think it is more important that you need to learn the fundamentals of how to code a game. There are many resources ready to guide you to the right direction. Please take a look at Roblox tutorial on making a game, or even tutorials from Youtube. This will give you more understandings on how to code a game. Your path is not easy, and the first step is always the hardest, please do not give up on your idea.

Lastly, please do accept one of my posts as a solution to end this conversation. Thank you!

1 Like