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

Cloning local scripts into the backpacks of two players does not work at all?

Asked by 5 years ago
Edited 5 years ago

(All Fe) The script is supposed to clone a local script from the ReplicatedStorage when a round starts and place it into the player's Backpack. Currently, the local script only works when I put it in the starter pack, if it's not initially in the starter pack it doesn't work at all. The server script that goes along with it is in ServerScriptService.

This is the set-up: https://gyazo.com/27a7bad35bb3ac1f12629d5a1caf94be This is the code in the local script:

local player = game.Players.LocalPlayer
local rep = game:GetService("ReplicatedStorage")
local uis = game:GetService("UserInputService")

local assets = rep.Assets.Basic

local mod = require(rep.Modules.ModuleScript)
local event = rep.RemoteEvents.Combat

local mouse = player:GetMouse()

print('hi')

local rP = {
    idle = assets.Idle:Clone(), -- idle [1]
    walk = assets.Walk:Clone(), --walk [2]
}

local char = player.CharacterAdded:Wait()
local rh = char:WaitForChild("RightUpperArm")
local lh = char:WaitForChild("LeftUpperArm")
local rf = char:WaitForChild("RightLowerLeg")
local lf = char:WaitForChild("LeftLowerLeg")


local ts = {"Set Animations"}
event:FireServer(ts)

print('fired')

mouse.Button1Down:Connect(function()
    local t = {"Right Punch"}
    event:FireServer(t)
end)

mouse.Button2Down:Connect(function()
    local t = {"Left Punch"}
    event:FireServer(t)
end)

uis.InputBegan:Connect(function(input, gpe)
    if gpe == false then
        if input.KeyCode == Enum.KeyCode.F then
            local t = {"Left Kick"}
            event:FireServer(t)
        end
    end
end)

This is the code to place it into the backpack:

local move1 = rep:FindFirstChild("FightingStyles_Local_Script"):FindFirstChild("Basic"):FindFirstChild("LocalScript"):Clone()
    move1.Parent = plr1.Backpack

    move1:Clone().Parent = plr2.Backpack

Any help is greatly appreciated!

0
You can get mouse input from UserInputService by looking at inputObject.UserInputType in the InputBegan parameter. xPolarium 1388 — 5y
0
Just going to let you know line 19: `Player.CharacterAdded:Wait()` can bug out sometimes and cause an infinite yield making the rest of the script below it to not even load, I suggest just doing `Player.Character` and adding `wait(1)` after it DragonSkyye 517 — 5y
0
Thanks iGlaciem 72 — 5y

Answer this question