Hello! Me and my friend decided to add premium benefits to our game. We decided that premium players will get an exclusive premium only tool (They have to click a part to get it).
The script doesn’t seem to work and I don’t know why.
This is a regular script I use for the regular tools. It gives players a tool once they click the part. It works perfectly.
local ToolNames = {"PremiumBlade", "Item", "Item"}
local Storage = game:GetService("ServerStorage")
local Part = script.Parent
local ClickDetector = Part:WaitForChild("ClickDetector")
ClickDetector.MouseClick:connect(function(Player)
if Player and Player.Character then
local Backpack = Player:WaitForChild("Backpack")
for i = 1, #ToolNames do
local Tool = Storage:FindFirstChild(ToolNames[i])
if Tool and not Backpack:FindFirstChild(Tool.Name) then
Tool:clone().Parent = Backpack
end
end
end
end)
This is for the premium only tool. It is broken and I don’t know why.
local Players = game:GetService("Players")
local player = Players.LocalPlayer
if player.MembershipType == Enum.MembershipType.Premium then
local ToolNames = {"PremiumBlade", "Item", "Item"}
local Storage = game:GetService("ServerStorage")
local Part = script.Parent
local ClickDetector = Part:WaitForChild("ClickDetector")
ClickDetector.MouseClick:connect(function(Player)
if Player and Player.Character then
local Backpack = Player:WaitForChild("Backpack")
for i = 1, #ToolNames do
local Tool = Storage:FindFirstChild(ToolNames[i])
if Tool and not Backpack:FindFirstChild(Tool.Name) then
Tool:clone().Parent = Backpack
end
end
end
end)
Thank you for reading.