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

"attempt to compare number with string"?

Today... on line 3..

"19:01:05.347 - Workspace.Teleport button.Part.Teleport Script:3: attempt to compare number with string"

what does this mean?

script.Parent.ClickDetector.MouseClick:Connect(function(plr)

if plr.leaderstats.Money.Value > 1 then

    plr.Character.HumanoidRootPart.CFrame = CFrame.new(281, 30.6, -26)

end

end)

just another thing, where is a good place to look for learning how to script and all the properties of the roblox studio, is the roblox wiki good for that?

3 comments

0

I also have the same problem

0

On Line 3 game.ReplicatedStorage.BuyItem.OnServerEvent:Connect(function(plr,weight) if plr.leaderstats.Strength.Value >= weight.Price.Value then plr.leaderstats.Strength.Value = plr.leaderstats.Strength.Value - weight.Price.Value

0

game.ReplicatedStorage.BuyItem.OnServerEvent:Connect(function(plr,weight) if plr.leaderstats.Strength.Value >= weight.Price.Value then plr.leaderstats.Strength.Value = plr.leaderstats.Strength.Value - weight.Price.Value

2 answers

✓ Accepted answer

It seems that plr.leaderstats.Money is a StringValue object. Try changing it to be a IntValue or NumberValue object.

Roblox Development Hub is a great place to read on scripting, and also contains the API for all properties and objects in the game.

2 comments

0

Thanks!

0

You can use "tonumber(args)" to convert the string to a number

Seems like the leaderstats money value is a string. If your using a string value, use NumberValue or IntValue instead

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