I am making a tycoon game on Roblox, but a part of my code doesn't work... this problem occurs for every single tycoon within my game (as they all share almost the same lines of code)... when the player purchases the weapon panels using the in-game cash, they should be getting the weapon in their inventory when they come in contact with the panel...but the player doesn't seem to be getting the weapon. Here is the part of code related to the weapon panel :
wep = script.Parent.WeaponName.Value
deb = true
giv = script.Parent.Giver
function touch(part)
local hum = part.Parent:FindFirstChild("Humanoid")
if hum then
local plr = game.Players:FindFirstChild(part.Parent.Name)
if plr then
if deb == true then
deb = false
giv.BrickColor = BrickColor.new("Really red")
local weapon = game.Lighting:FindFirstChild(wep)
local w2 = weapon:Clone()
w2.Parent = plr.Backpack
wait(script.Parent.RegenTime.Value)
giv.BrickColor = BrickColor.new("Bright violet")
deb = true
end
end
end
end
script.Parent.Giver.Touched:connect(touch)
Please help :(
I am not able to understand the problem in this giver script and as to why it doesn't give the player the particular weapon.
PROGRAMMING LANGUAGE : Lua
question from:
https://stackoverflow.com/questions/65897320/tycoon-game-on-roblox 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…