Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Gear Card gets gears from ServerStorage table?

Trying to Update and Modify the "Gear Card" used in Gear Wars games, but for some reason the Picked gear from the ServerStorage folder is not working...

Any person who made a "Gear Wars" game probably recognise this:

--Item Giver Script By Tenbelow--

local Tool = script.Parent

local gears = game.ServerStorage.Gears:GetChildren() -- Changed this



function onActivated()
 -- play sound
	magicSound = Tool.Handle:FindFirstChild("MagicSound")
	if magicSound == nil then return end
	magicSound:Play()

-- GOOD RANDOMIZATION CODE!! --Tenbelows weird randomisation code
	numLoops = math.random(0,math.floor(1000*time()))
	numLoops = numLoops - (math.floor(numLoops / 10000)*10000)
	for i = 1,numLoops do
		whichNum = gears[math.random(1,#gears)] -- Changed this
	end
-- END OF GOOD RANDOMIZATION CODE!

	print("Picked: ")
	print(whichNum)
	local root = whichNum:Clone()

	local instances = root:GetChildren()
	if #instances == 0 then
		root:Remove()
		return
	end

	root = root:GetChildren()
	if #root == 1 then
		root = root[1]
	else return end
	print(root)
	root.Parent = 
	Tool:remove()
end

function onEquipped()
	magicSound = Tool.Handle:FindFirstChild("MagicSound")
	if magicSound == nil then
		magicSound = Instance.new("Sound")
		magicSound.Parent = Tool.Handle
		magicSound.Volume = 1
		magicSound.SoundId = "http://www.roblox.com/asset/?id=35571070"
		magicSound.Name = "MagicSound"
	end
end

Tool.Activated:connect(onActivated)
Tool.Equipped:connect(onEquipped)pped:connect(onEquipped)

1 answer

Two things wrong with the script:

on line 25 you are cloning a number, you cant clone a number (local root = whichNum:Clone())

on line 38, you are getting the local player, you cant get the localplayer on a script.

script = server localscript = client

How would the server know which client you would be refering too.

nitpick: connect is deprecated use Connect

also ur randomization is completely uneccesary whichNum = math.random(1,#gears) is equally as random as all the other stuff you wrote there

4 comments

0

i didnt write most of the script, it was made a long time a go, im trying to revamp it so it will get a gear from serverstorage

0

does it work now ?

0

does it work now ?

0

no, you only said the things i did wrong, no improvements

This discussion is preserved as it was. New answers, comments, and votes are closed.