Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

is it possible to transfer the value from one leaderstat to another?

im trying to grab the value from one leaderstat and put it into another leaderstat, is that possible?

local ui = script.Parent
local player = game.Players.LocalPlayer

while wait() do
	local player = game.Players.LocalPlayer
	ui.Text = ""..player:WaitForChild("Equipped"):FindFirstChild("One").Value
end

function leftClick()
	player.Equipped.One.Value = player.Equipped.Current.Value
end

ui.MouseButton1Click:Connect(leftClick)

27 comments

0

you shouldnt be using a while loop like that, use GetPropertyChangedSignal, theres no point in concatenating an empty string, what exactly is player.Equipped.One and player.Equipped.Current and are they used on the server?

0

Player.Equipped.One is the ability equipped in the one slot and Player.Equipped.Current is the selected ability. Say you wanted to equip the fireball ability, you would press the fireball button and the Player.Equipped.Current which is a string would change to "FireBall" then you would press on the number that you want to equip the ability to i.e 1-5. Then when you press on 1 or 5 or whatever-

0

number between them, it should get the string value from the Current and set it to the Number that you pressed, in this case "One". the empty string is to just display the ability name

0

okay i understand the one and current now, but you still shouldn't need the empty string, i also didnt realise this earlier but its good practice to use local function over function, although it looks like this code should work unless the values need to be updated on the server too

0

I dont understand why it wont work

0

are the values being updated? you could check in studio playtesting with the explorer, i assume this script is a localscript (it uses LocalPlayer so it has to be), are the values (Equipped.XYZ & Equipped.Current ever accessed on the server? these are the only reasons i could think it isnt working

0

i dont exactly know what accessed on the server means

0

like ever called on a server script?

0

a server script (any Script or ModuleScript (required by a Script and not a LocalScript)) reading the Value of an Equipped Value

0

no, they arent

0

it could be that your UserInputService (or whatever you use to detect key presses) implementation isnt working correctly

0

oh the 1-5 buttons are a ui

0

the script i put on this post is from the 1 button

0

oh, well you should try using print to debug your code to see where it stops working

0

ok ill try that

0

i put a print in the function before and after the Player.Equipped.One.Value = player.Equipped.Current.Value and neither print came up

0

then its prboably that theres a gui above the one you want the MouseButton1Click event to be firing, instead its firing the one above, check if theres any guis (invisible or not) above it, it could also be because its a rounded gui and you're accidently clicking the image instead of the actual button

0

by accidently i mean that the image is above the textbutton, not that you're actually clicking the image but that could be it

0

i mean in the actual rendering, not the explorer

0
0

well it seems like it should be working, i have no idea why it isnt

0

this is the weirdest thing i have experienced

0

Oh, i know now, its because a while loop yields infinitely and you havent created a new thread for it, this can be solved with coroutine.wrap/coroutine.new & coroutine.resume or just by using GetPropertyChangedSignal

0

I was about to say i changed the while loop to player.Equipped.One.Changed:Connect(function(newVal) and that fixed it

0

alright, thats good to know, but you should use player.Equipped.One.Changed:GetPropertyChangedSignal("Value") instead of .Changed

0

alright ill do that

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.