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

Help me solve this RemoteEvent issue?

Asked by 5 years ago
Edited 5 years ago

I'm trying to make an equip and un-equip system for my RPG that works in FE. I've used RemoteEvents and it works when you press play in studio(of course it does) however when I press test it doesn't and the server doesn't report any errors regarding it. Here are the scripts:

Local Script

local player = game.Players.LocalPlayer
local inv = player.PlayerGui.MainGUI.Menu.Holder.Inventory:WaitForChild("Main")
function onClicked()
    if script.Parent.Parent.Equipped.Value == false then
        script.Parent.Parent.Parent.WeaponName.Value = script.Parent.Parent.Name
        for index, name in pairs(player.Weapons.WeaponName:GetChildren()) do
            name.Name = script.Parent.Parent.Name
        end
        for index,spot in pairs(inv:GetChildren()) do
        if spot.Name == spot.Parent.WeaponName.Value then 
            game.ReplicatedStorage.Equip:FireServer()
            spot.Equipped.Value = true
            spot.TextButton.Text = "Un-equip"
            for index, weapon in pairs(player.Character.Equipped:GetChildren()) do
                player.PlayerGui.Combat.Weapon.Value = weapon
            end
        elseif spot.Name ~= spot.Parent.WeaponName.Value then
            spot.Equipped.Value = false
            spot.TextButton.Text = "Equip"
        end
    end
    elseif script.Parent.Parent.Equipped.Value == true then
        for index,spot in pairs(inv:GetChildren()) do
            game.ReplicatedStorage.UnEquip:FireServer()
            spot.Equipped.Value = false
            game.Players.LocalPlayer.PlayerGui.Combat.Weapon.Value = nil
            spot.TextButton.Text = "Equip"
            script.Parent.Parent.Parent.WeaponName.Value = "N/A"
            for index, name in pairs(player.Weapons.WeaponName:GetChildren()) do
                name.Name = "N/A"
            end
        end
    end
end
script.Parent.MouseButton1Click:connect(onClicked)

Script

game.ReplicatedStorage.Equip.OnServerEvent:Connect(function(player)
    for index, weapons in pairs(player.Character.Equipped:GetChildren()) do
        weapons:Destroy()
    end
    for index, chosen in pairs(game.ReplicatedStorage.WeaponFile:GetChildren()) do
        for index, name in pairs(player.Weapons.WeaponName:GetChildren()) do
            if chosen.Name == name.Name then
                local Scythe = chosen.Scythe
                Scythe.Parent = player.Character.Equipped
                local weld = Instance.new("Weld")
                weld.Part0 = player.Character.Ring
                weld.Part1 = Scythe.Part
                weld.Parent = Scythe.Part
            end
        end
    end
end)
0
Local script? cherrythetree 130 — 5y
0
The button script is the local script and the RemoteEvent script is a regular script DeadGambit 2 — 5y
0
Try to add WaitForChilds in the regular script for Characters n such Natsu88 0 — 5y
0
Hmm that didn't seem to work. Thanks for the suggestion though! DeadGambit 2 — 5y

Answer this question