How would I go about making an arm wrestling system like Arm Wrestle. By this I mean where you fight an NPC with a power and bar system.
I’m not that good at coding but how do you want the player to be able to fight? clicking?
Yes, by clicking their screen like arm wrestle simulator.
You can have a power variable that gose up when clicked(player power - npc power)and gose down by power power / npc power, save the total value to a var called power. You with have to tween a bar the power var.
Sorry if i didn’t help, it is 12 am for me and im tired.
You could define an int value that constantly decreasing by opponent strength, but when you click it increases by player strength and you can just tween the bar. This script would look something like this:
I rushed this script, just to give you an idea of how a system like this would work
local TweenService = game:GetService("TweenService")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local visualframe = VISUAL_BAR
local npc_strength = 100
local player_strength = 200
local max_track = 1000
local min_track = 0
local fighting = true
local tracking = ((npc_strength + player_strength) / 2) + (max_track / 2)
function endscript()
fighting = false
script:Destroy()
end
-- tracking interface
function trackingChanged()
if tracking >= max_track then -- if player won
print("player won wrestling")
endscript() -- pack up your script
elseif tracking <= min_track then -- if npc won
print("npc won wrestling")
endscript() -- pack up your script
end
local num = tracking / max_track
if num > 1 then
num = 1
elseif num < 0 then
num = 0
end
TweenService:Create(visualframe.Fill, TweenInfo.new(0.1), {Size = UDim2.fromScale(num, 1)}):Play() -- tweening fill to tracking (ex: .5,0,1,0 )
end
-- tracking
mouse.Button1Down:Connect(function()
trackingChanged()
tracking += player_strength
end)
task.spawn(function()
while task.wait(1) do
if fighting then
trackingChanged()
tracking -= npc_strength
end
end
end)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.