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

Players.Oficcer_F.Backpack.BananaDropper.DropBanana:15: attempt to compare number with userdata?

Asked by
Oficcer_F 207 Moderation Voter
6 years ago

Trying to only be able to place 3 bananas on the ground, and then remove the tool and then needing to buy the tool every time... This is my local script:

01tool = script.Parent
02player = game.Players.LocalPlayer
03replicatedSotrage = game.ReplicatedStorage
04script.Parent:WaitForChild("BananLeft")
05BananLeft = script.Parent.BananLeft
06tool.Equipped:Connect(function(mouse)
08player.PlayerGui.ScreenGui.BananCounter.Visible = true
09mouse.Button1Down:Connect(function()
10 
11local position = mouse.Hit.p
12local head = player.Character.Head
13local distance = (head.Position - position).magnitude
14if distance < 25 and BananLeft  > 0 then
15 
View all 34 lines...

Server script:

01replicated = game.ReplicatedStorage.SpawnBanana.OnServerEvent:Connect(function(player, position)
02    local banana = game.ServerStorage.Banana:Clone()
03    banana.Parent = game.Workspace
04    banana.Position = Vector3.new(position.X, position.Y, position.Z)
05end)
06 
07 
08game.ReplicatedStorage.DestroyTool.OnServerEvent:Connect(function(player, backpackTool, starterGearTool)
09 
10    backpackTool:Destroy()
11    starterGearTool:Destroy()
12end)

This is the tool ancestry:

BananaDropper (Tool) DropBanana (Local script) BananLeft (IntValue) Handle (Part)

Please help Thanks Is this osmething with that the intValue is inside the player??

1
legend TheluaBanana 946 — 6y
0
wut Oficcer_F 207 — 6y

1 answer

Log in to vote
2
Answered by
aazkao 787 Moderation Voter
6 years ago
Edited 6 years ago

You are comparing an instance to a number, you have to get the value of the instance to compare it to a number

01tool = script.Parent
02player = game.Players.LocalPlayer
03replicatedSotrage = game.ReplicatedStorage
04script.Parent:WaitForChild("BananLeft")
05BananLeft = script.Parent.BananLeft
06tool.Equipped:Connect(function(mouse)
08player.PlayerGui.ScreenGui.BananCounter.Visible = true
09mouse.Button1Down:Connect(function()
10 
11local position = mouse.Hit.p
12local head = player.Character.Head
13local distance = (head.Position - position).magnitude
14if distance < 25 and BananLeft.Value  > 0 then--------
15 
View all 34 lines...
1
Yeah I figured that out like 2 seconds after I published it lol, but thanks for answering anyway! Oficcer_F 207 — 6y
0
Thanks for accepting the answer, if anyone else stumbles upon this they can learn from it too aazkao 787 — 6y
Ad

Answer this question