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

A script should work every time my chr appears but it does it when anybody appears,how to fix this?

Btw chr in the title means character Here's the script:

local me = game.Players.iiiAmericanLight
local chr = me.Character

local swr = game.ReplicatedStorage:FindFirstChild("Meliodas Sword")
local pfr = game.ReplicatedStorage:FindFirstChild("Purgatory Flame")
local scr = game.ReplicatedStorage:FindFirstChild("Orbiting DP")

local sw = swr:Clone()
local pf = pfr:Clone()
local sc = scr:Clone()

sw.Parent = me.Backpack
pf.Parent = me.Backpack
sc.Parent = me.Backpack

The script is located in the StarterGUI and it's local.It should only trigger when my character appears, but it triggers on anyone instead.I would really appreciate some help.

1 answer

✓ Accepted answer

Your script is only checking if you are in players, not if it's you using the script. Meaning anyone who runs this script is going to check if you are in players and give you the weapon.

Try this

local me = game:GetService("Players").LocalPlayer
if me.Name == "iiiAmericanLight" then -- Checks if iiiAmericanLight is using script
local chr = me.Character

local swr = game.ReplicatedStorage:FindFirstChild("Meliodas Sword")
local pfr = game.ReplicatedStorage:FindFirstChild("Purgatory Flame")
local scr = game.ReplicatedStorage:FindFirstChild("Orbiting DP")

local sw = swr:Clone()
local pf = pfr:Clone()
local sc = scr:Clone()

sw.Parent = me.Backpack
pf.Parent = me.Backpack
sc.Parent = me.Backpack
end

Hope this helps.

2 comments

0

Works perfectly, thanks!

0

Glad I could be of use. :)

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