--MainModule local _M = {} script.Parent = game.Workspace function _M.give() game:GetService("InsertService"):LoadAsset(842321306).Parent = game.Players.Player1.Backpack end return _M --Script local sword = require(game.Workspace.MainModule) sword.give()
So what I am trying to do here is insert a sword I made yesterday into a script builder with module scripting I am new to module scripting and I don't fully know what I am doing I was using the wiki but nothing seemed to happen, please can someone explain to me. I didn't know if I needed to add the errors I was getting please tell me if I need to.
--MainModule local _M = {} script.Parent = game.Workspace function _M.give(Player) game:GetService("InsertService"):LoadAsset(842321306).Parent = Backpack end return _M --Script local sword = require(game.Workspace.MainModule) local AllowPlayers = {"Player1","Player2","etc"} function CheckPlayer(Player) --Checks if the player is in the list for _,p in pairs(AllowPlayers) do if p == Player.Name then return true end end end game.Players.PlayerAdded:connect(function(Player) if CheckPlayer() then sword.give(Player.Backback) end end
Personally I'd do this, this allows for multiple players to be given the sword and it activates when a new player is added to Players instead of trying to give the sword straight away when the game starts. Hope this helps Not I wrote this without testing it, it looks like it should work to me but. human arror and whatnot. Somethign like this should definitely work though