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

Script, located in ServerScriptService, works in studio, but does not work in game?

I am trying to make a script that gives a weapon only to me. It only hands me a weapon to a player that has my name. Here is the script:

function Added(plr)
	wait(1)
	if plr.Name == "EliteRayGawnX2" then
		local Katana = script.Katana
		local KatanaClone = Katana:Clone()
		KatanaClone.Parent = plr.Backpack
	end
end
game.Players.PlayerAdded:connect(Added)

It works as intended in studio tests. The weapon but when i actually go to play the game, it does not work. Is it a problem in the script? Or with Roblox?

2 comments

0

Show me your explorer please

0

ServerScriptService>Script>Katana

1 answer

✓ Accepted answer

Put Katana in Lighting and put script in ServerScriptService:

game.Players.PlayerAdded:Connect(function(plr)
	if plr.Name == "EliteRayGawnX2" then
		local katana = game.Lighting.Katana
		katana:Clone().Parent = plr.BackPack
	end
end

4 comments

0

Lighting is easily exploitable

0

Do ServerStorage then.

0

ReplicatedStorage is more for Replicating Items, as it has it in it's name. But, either works, ServerStorage or ReplicatedStorage.

0

Thanks!

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