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

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

Asked by 4 years ago

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?

0
Show me your explorer please orcazate 170 — 4y
0
ServerScriptService>Script>Katana EliteRayGawnX2 124 — 4y

1 answer

Log in to vote
0
Answered by
Geobloxia 251 Moderation Voter
4 years ago

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
0
Lighting is easily exploitable orcazate 170 — 4y
0
Do ServerStorage then. Geobloxia 251 — 4y
0
ReplicatedStorage is more for Replicating Items, as it has it in it's name. But, either works, ServerStorage or ReplicatedStorage. killerbrenden 1537 — 4y
0
Thanks! Geobloxia 251 — 4y
Ad

Answer this question