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

What is wrong with this?

Asked by 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
local player = game.Players.LocalPlayer
local currency = player:WaitForChild('leaderstats').Points
local amount = 5
local tool = game.ServerStorage:WaitForChild('Firebrand')
script.Parent.MouseButton1Click:connect(function()
 if currency.Value >= amount and not player.Backpack:FindFirstChild("Firebrand")or player.Character:FindFirstChild('Firebrand') then
  -- They Dont Have it
  local newtool = tool:Clone()
  newtool.Parent = player.Backpack
 else
  script.Parent.Text = 'Purchase Failed'
 end
end)
1
We need to know what is wrong with it in order to answer your question. Do you get errors in output? What does it not do that it's supposed to do? Legojoker 345 — 8y
0
I can test the game but it does not do anything SpicyLemonXII 0 — 8y

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
8 years ago

ServerStorage is exactly that -- storage for the server -- not the client. LocalScripts do not have access to anything in ServerStorage -- ROBLOX won't bother sending them those files.

If you want to make a model available to clients (i.e., LocalScripts) you have to use ReplicatedStorage.


Also, your order-of-operations is wrong with or, and, and not.

if a and not b or c is interpreted as if (a and (not b)) or c then. Thus the purchase will go through if they have it in their character, even if they don't have enough money.

Ad

Answer this question