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

This script shows no errors in output or script analysis, It refuses to work, Help?

Asked by 3 years ago
Edited 3 years ago

So I decided to make a code that allows only me, no one else to be able to get a certain gear in game. Here is the script...

local Players = game:GetService("Players")
local Player = game.Players.LocalPlayer
local FlowerBasket = game:GetService("ReplicatedStorage"):WaitForChild("FlowerBasket")
local Backpack = Player:FindFirstChild("Backpack")
wait(2)
Players.PlayerAdded:Connect(function()
if script.Parent.Username.Value == "543752773" then
Backpack.FlowerBasket:Clone()

end 
end)

I really need to stop trying to code at 3:00 in the morning its making me confused Its probably line 8, but I don't know how to fix that.

0
For some reason it deletes itself in SSS, have a fix? ifreakinlostmyacount 52 — 3y
0
I figured out the problem, Mikeal semi help so I'm going to say you answerd my question, thank you :) ifreakinlostmyacount 52 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

try assigning a variable to

game:GetService("ReplicatedStorage"):WaitForChild("FlowerBasket") 

such as

 Basket = game:GetService("ReplicatedStorage"):WaitForChild("FlowerBasket")

and after the cloning part add the .Parent

Basket:Clone()
Basket.Parent = Backpack

as i notice you used

local Player = game.Players.LocalPlayer

so that's a local script ... I suggest doing .PlayerAdded in a server script so when the server detects the player added it will clone the tool to the player backpack. If u want to get the player form server script the .PlayerAdded will give it to you as a parameter

Players.PlayerAdded:Connect(function(player)
end)
Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Like @Mikael20143 said, you should use a server script in SSS (ServerScriptService) and put the tool or whatever inside RepStorage or ServerStorage, you can try checking the UserId instead of the Value thing:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local FlowerBasket = ReplicatedStorage:WaitForChild("FlowerBasket")

game.Players.PlayerAdded:Connect(function(player)
    if player.UserId == yourUserId then -- Your userid should NOT be a string, it's a number so it will be fine
        FlowerBasket:Clone().Parent = player:WaitForChild("Backpack")
    end
end)

Answer this question