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

Help with RemoteFunctions and RemoteEvents?

Asked by 10 years ago

So I am using RemoteEvents to do things to a character, such as change their appearance(with FilteringEnabled). Everything works in solo, except, that the events don't run in Server. One part of the script, since none of it works in server:

-- Inside server script
local event = Instance.new("RemoteEvent")
event.Parent = game.workspace:WaitForChild('Configuration'):WaitForChild('Events')
event.Name = "ApplyAppearance"
event.OnServerEvent:connect(function(player,arguments)
    char = game.workspace:WaitForChild(player.Name)
    print('Event Fired')
    charParts = char:GetChildren()
    for i = 1,#charParts do
        if charParts[i].className == 'Pants' or charParts[i].className == 'Shirt' or charParts[i].className == 'ShirtGraphic' or charParts[i].className == 'Hat' or charParts[i].className == 'CharacterMesh' then
            charParts[i]:Remove()
        elseif charParts[i].className == 'Humanoid' then
            charParts[i].WalkSpeed = arguments[16]
            charParts[i].Name = tostring(arguments[4])
            charParts[i].Health = arguments[3]
            charParts[i].MaxHealth = arguments[2]
        elseif charParts[i].Name == 'Torso' then
            if charParts[i]:FindFirstChild('roblox') then
                charParts[i]:FindFirstChild('roblox'):remove()
            end
        end
    end
    shirt = Instance.new('Shirt',char)
    shirt.ShirtTemplate = 'rbxassetid://' .. tonumber(arguments[7])
    pants = Instance.new('Pants',char)
    pants.PantsTemplate = 'rbxassetid://' .. tonumber(arguments[8])
    char:WaitForChild('Animate'):WaitForChild('idle'):WaitForChild('Animation1').AnimationId = 'rbxassetid://' .. tonumber(arguments[5])
    char:WaitForChild('Animate'):WaitForChild('idle'):WaitForChild('Animation2').AnimationId = 'rbxassetid://' .. tonumber(arguments[6])
    char:FindFirstChild('Head'):FindFirstChild('face').Texture = 'rbxassetid://' .. tonumber(arguments[9])
    if not char:FindFirstChild('Assassin Hat') then
        hatPart = Instance.new('Part',char)
        hatPart.Name = 'Assassin Hat'
        hatPart.CanCollide = false
        char:FindFirstChild('Head').CanCollide = false
        hatPart.Size = Vector3.new(1,1,1)
        hatPartMesh = Instance.new('SpecialMesh',hatPart)
        hatPartMesh.MeshId = 'rbxassetid://' .. tonumber(arguments[10])
        hatPartMesh.TextureId = 'rbxassetid://' .. tonumber(arguments[11])
        hatPartMesh.Offset = Vector3.new(0,0.1,0.1)
        hatPartWeld = Instance.new('Weld',char:FindFirstChild('Head'))
        hatPartWeld.Part0 = char:FindFirstChild('Head')
        hatPartWeld.Part1 = hatPart
        hatPartWeld.C0 = CFrame.new(0,0,0)
        hatPartWeld.C1 = CFrame.new(0,0,0)
    end
    if not char:FindFirstChild('SwordPart') then
        swordPart = Instance.new('Part',char)
        swordPart.Name = 'SwordPart'
        swordPart.Size = Vector3.new(1, 0.8, 5)
        swordPart.CanCollide = false
        swordPartMesh = Instance.new('SpecialMesh',swordPart)
        swordPartMesh.MeshId = 'rbxassetid://' .. tonumber(arguments[12])
        swordPartMesh.TextureId = 'rbxassetid://' .. tonumber(arguments[13])
        swordPartMesh.Scale = Vector3.new(1.7,1.7,1.7)
        swordPartWeld = Instance.new('Weld',char:WaitForChild('Torso'))
        swordPartWeld.Part0 = char.Torso
        swordPartWeld.Part1 = swordPart
        swordPartWeld.C0 = CFrame.new(0,0,0)
        swordPartWeld.C1 = CFrame.new(1,-1,-2.5) * CFrame.Angles(0,1,-1.5)
    end
    if not char:FindFirstChild('PistolPart') then
        pistolPart = Instance.new('Part',char)
        pistolPart.Name = 'PistolPart'
        pistolPart.Size = Vector3.new(1, 2, 1)
        pistolPart.CanCollide = false
        pistolPartMesh = Instance.new('SpecialMesh',pistolPart)
        pistolPartMesh.MeshId = 'rbxassetid://' .. tonumber(arguments[14])
        pistolPartMesh.TextureId = 'rbxassetid://' .. tonumber(arguments[15])
        pistolPartMesh.Scale = Vector3.new(1.5, 1.5, 1.5)
        pistolPartWeld = Instance.new('Weld',char:WaitForChild('Torso'))
        pistolPartWeld.Part0 = char.Torso
        pistolPartWeld.Part1 = pistolPart
        pistolPartWeld.C0 = CFrame.new(0,0,0)
        pistolPartWeld.C1 = CFrame.new(0.6,0,1) * CFrame.Angles(1.5,4.7,0)
    end
end)
-- Inside Local Script

local appearance = game.workspace:WaitForChild('Configuration'):WaitForChild('Events'):WaitForChild("ApplyAppearance")

appearance:FireServer({char.Name,health,maxhealth,humname,Idle,Idle2,ShirtTexture,PantsTexture,
    FaceTexture,HatMesh,HatTexture,SwordMesh,SwordTexture,PistolMesh,PistolTexture,WalkSpeed})


0
Haha, I just had that problem. Anyways, script, please? Redbullusa 1580 — 10y
0
Posted. killerkill29 35 — 10y
0
Is there anything in the output in the console (F9) in both local & server pane? Redbullusa 1580 — 10y
0
Nevermind. I got it to work. killerkill29 35 — 10y

Answer this question