I am not quite sure if my script would work because I am soon to get premium but I have not got it yet and I am still a pretty new developer so help would be appreciated.
here’s my script:
local Players = game:GetService(“Players”)
local player = Players.LocalPlayer
local killall = game.Workspace.Tool
local killall:Clone = killall:Clone()
killallclone.Parent = workspace
if player.MembershipType == Enum.MembershipType.Premium then
killall.Parent = player
elseif Enum.MembershipType.None then
killallclone:Destroy()
end
would this script give the “killall” tool to a premium and delete the “killallclone” if there isn’t a premium?
that’s what I am trying to do.
sorry if this is in the wrong topic. but would this script work???
one last question would all the scripts inside my tool (even though I don’t have any yet) work?
(there is probably a much easier way to do it but I do not know how to do it yet)
Speaking of LocalScripts, I am not quite certain whether the tool will be successfully given to the player themselves, but the concern is mostly on what happens next if the tool is given to the player. This tool will not replicate to other players, and should probably work as accordingly somehow.
I don’t know about the detail of the original tool being in workspace. There will be an issue if someone magically picks this tool up, therefore causing an issue and breaking the code.
This line: local killall:Clone = killall:Clone()
…will never work, because : is reserved character to an operator.
You should proooobably do that, but I would advise otherwise and work on the same code but rewriting it a little around it.
Although that, it would be extremely helpful if you provided the purpose of this tool and the script itself. Context matters a lot in most cases of scripting support.
There are a lot of ways to do this, but I can try to figure out this in the best way possible:
Store the tool in ReplicatedStorage, very important to manage your objects that exists for storaging.
Use a server script and store this script in ServerScriptService, a canonical service for server scripts.
Write the code, remember to use correct services like Players. Also each Player has a Backpack which should contain these tools.
local Players = game:GetService("Players")
local PremiumTool = ReplicatedStorage.Tool
Players.PlayerAdded:Connect(function(player)
if player.MembershipType == Enum.MembershipType.Premium then
PremiumTool:Clone().Parent = player.Backpack -- a backpack is used to hold tools, not player object
end
end)
Beware that this code doesn’t give you the tool again after you died.