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

The shop script's variable is not setting, help needed?

Asked by
iHavoc101 127
4 years ago

Fix this code pls

print("Shop Script Loaded") 

local Saber = ["Kylo Ren's Crossguard Lightsaber"]
Door = script.Parent 
local debounce = false 

function getPlayer(humanoid) 
local players = game.Players:children() 
for i = 1, #players do 
if players[i].Character.Humanoid == humanoid then return players[i] end 
end 
return nil 
end 
function onTouched(hit) 
if debounce == false then 
local human = hit.Parent:findFirstChild("Humanoid") 
if (human == nil) then return end 
local player = getPlayer(human) 
debounce = true 
if (player == nil) then return end 
local stats = player:findFirstChild("leaderstats") 
local sp = stats:findFirstChild("Captures") --Change "Money" to the type of currency you have.
if sp == nil then return false end 
if (sp.Value >=20) then --Amount of how much the weapon will go for,Change "100".
sp.Value = sp.Value - 20 --Put the same exact number here as you did above.
print("Enough Money") 
game.Lighting.Saber:clone().Parent = player.Backpack --Change PUTTOOLNAMEHERE to your weapons name.
Door.BrickColor = BrickColor.new(21) --MAKE SURE YOU PUT THE WEAPON/TOOL INTO LIGHTING.
wait(2) 
Door.BrickColor = BrickColor.new(37) --Leave the rest of this alone.
debounce = false 
else debounce = false 
end 
end 

end 

connection = Door.Touched:connect(onTouched) 
0
for the love of god please format your coding mightydifferent 85 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

try setting this:

game.Lighting.Saber:clone().Parent = player.Backpack

to this:

game.Lighting[Saber]:clone().Parent = player.Backpack
Ad

Answer this question