Ad
Log in to vote
-1

Why are tools disappearing when the round starts??

Asked by
xoquez -11
3 days ago
Edited 3 days ago

OK so MY game works pretty well, keep in mind im new to scripting. theres multiple maps and every map is chosen randomly. then when players are tped onto the map a random tool aka weapon gets chosen and puts it in the players backpack. now the sword and meelee items work great, like the energy sword, but a few of the guns like the laser gun and tommy gun and the knife have issues. basically when the weapon is chosen it equips it on the player immediatly and it shows that you dont have that weapon in your hands or physically. then if u click it disapears. now I did try to reequip the tool and the item did work then its something about when it starts like idk. ALSO keep in mind these gears are imported directly from the roblox avatar shop/catalog. so these are roblox's models or tools. this is really weird can someone help? I would appreciate it.

this is the local script in the laser gun and only a part of it that I think it may have something to do.

function Equipped(Mouse)
    Character = Tool.Parent
    Player = Players:GetPlayerFromCharacter(Character)
    Humanoid = Character:FindFirstChild("Humanoid")
    if not CheckIfAlive() then
        return
    end
    PlayerMouse = Player:GetMouse()
    Mouse.Button1Down:connect(function()
        InvokeServer("MouseClick", {Down = true})
    end)
    Mouse.Button1Up:connect(function()
        InvokeServer("MouseClick", {Down = false})
    end)
    Mouse.KeyDown:connect(function(Key)
        InvokeServer("KeyPress", {Key = Key, Down = true})
    end)
    Mouse.KeyUp:connect(function(Key)
        InvokeServer("KeyPress", {Key = Key, Down = false})
    end)
end

function Unequipped()
    for i, v in pairs(Animations) do
        if v and v.AnimationTrack then
            v.AnimationTrack:Stop()
        end
    end
    Animations = {}
end

Tool.Equipped:connect(Equipped)
Tool.Unequipped:connect(Unequipped)
0
Let us see the script... vincentthecat1 169 — 3d
0
i think this is this script xoquez -11 — 3d
0
it might fall throughbt he void before being in the backpack A_Mp5 146 — 3d

1 answer

Log in to vote
0
Answered by 3 days ago

My Best Guess Is To First Add A Folder in Replicated Storage Named "Items" And Put The Items In The Folder Then Add A Script In ServerScriptService Named "BackpackSave" --Do not add the "" :D

And The Script Should be like this

local dataStorageService = game:GetService("DataStorageService") local datastore = dataStorageService:GetDataStore("BackpackSave")

game.Players.PlayerAdded:connect(function(player) -- <---- Waits till The Player Has Fully Loaded :) pcal(function() local tool = datastore:GetAsync("User"..player.UserId) if tool then for i,v in pairs(tool) do local toolFound = game.ReplicatedStorage.Items:FindFirstChild("v") if toolFound then toolFound:Clone.Parent = player.Backpack toolFound:Clone.Parent = player.StarterGear end end end) end) game.Players.PlayerRemoving:connect(function(player) pcall(function() local toolSave = { } for i, tool in pairs(player.Backpack:GetChildren()) do if tool then table.insert(toolSave,tool.Name) end end datastore:GetAsync("User"..Player.UserId,toolSave) end) end)

--My Best Guess Idk try it .-. It Even Keeps Your things If you leave but idk how to do it for not leaving to save items :D

Ad

Answer this question