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.
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.
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.
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.
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)
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.
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.