Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

"attempt to compare number with string"?

Asked by 5 years ago

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?

0
I also have the same problem An_AverageBuilder 0 — 3y
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 An_AverageBuilder 0 — 3y
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 An_AverageBuilder 0 — 3y

2 answers

Log in to vote
1
Answered by
chomboghai 2044 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

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.

0
Thanks! Pr_ogram 17 — 5y
0
You can use "tonumber(args)" to convert the string to a number Formidable_Beast 197 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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

Answer this question