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

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

Asked by
Echtic 128
5 years ago

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

Log in to vote
0
Answered by
T1mes 230 Moderation Voter
5 years ago
Edited 5 years ago

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.

0
Works perfectly, thanks! Echtic 128 — 5y
0
Glad I could be of use. :) T1mes 230 — 5y
Ad

Answer this question