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

Im trying to make a fighting game but the weapons dont work in fe?

Asked by 5 years ago

Hello. Im trying to make a fighting game and i have got gui and everything. When i press the button for the gun in the editor i get it but not in the actual game. There it doesnt work

so i have a screengui with a textbutton in it the textbutton i made a localscript which holds following code:

script.Parent.MouseButton1Click:Connect(function()

    local plr = game.Players.LocalPlayer
    local Event = game.ReplicatedStorage.Equipped   
    Event:FireServer("Aug")

end)

the screengui is in serverstorgae

in the serverstorage is also my tool called "Aug"

in serverscriptservice i have a normal script with following code:

game.Players.PlayerAdded:Connect(function(plr)

    local CloneMe = game.ServerStorage.ScreenGui:Clone()
    CloneMe.Parent = plr.PlayerGui

end)

-------------------------------------------------------------------------------------------------------------------------------------------------------

game.ReplicatedStorage.Equipped.OnServerEvent:Connect(function(plr,Message)

    local Weapon = game.ServerStorage:FindFirstChild(Message)
    Weapon:Clone()
    Weapon.Parent = plr.Backpack

end)

and i have a remoteevent called "Equipped" in replicatedstorage

I would appreciate any help

0
Why aren't all these items/scripts/remotes within ReplicatedStorage? Then a RemoteHandler type folder with the respective remote scripts, if needed, in ServerScriptService... ABK2017 406 — 5y
0
First of all, if the screen gui is already going to be added to the player then just place it under starter gui? yellp1 193 — 5y
0
No. User#19524 175 — 5y
0
ok... and why not? yellp1 193 — 5y

1 answer

Log in to vote
0
Answered by
ABK2017 406 Moderation Voter
5 years ago

If it's helpful, here is a similar "giver" script within a block (its not in a GUI, but maybe you can alter it). Remove the Team part if it doesn't apply.

local button = script.Parent
local startcolor = button.BrickColor
local DB = false

local toolfolder = button.Parent["Tool"]
local toolstorage = {}
for i, tool in pairs(toolfolder:GetChildren()) do
    table.insert(toolstorage, tool:clone())
end
toolfolder:Destroy()

local block = button.Parent:FindFirstChild("Block")
if block ~= nil then
    if block:FindFirstChild("NameDisplay") then
        if block.NameDisplay.TextLabel.Text == "Tools" then
            if #toolstorage > 0 then
                block.NameDisplay.TextLabel.Text = toolstorage[1].Name
            else
                block.NameDisplay.TextLabel.Text = ""
            end
        end
    end
end


button.Touched:connect(function(hit)
    if DB then return end
    if hit == nil then return end
    if hit.Parent == nil then return end

    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player ~= nil then
        if player:FindFirstChild("Backpack") then
            local allow = true
            if #allow_team > 0 then
                local teams = game:GetService("Teams"):GetChildren()
                if #teams > 0 then
                    allow = false
                    for i, team in pairs(teams) do
                        for i, allowedteamname in pairs(allow_team) do
                            if team.Name == allowedteamname then
                                if player.TeamColor == team.TeamColor then
                                    allow = true
                                end
                            end
                        end
                    end
                end
            end
            if not allow_duplicates then
                for i, tool in pairs(toolstorage) do
                    if player.Backpack:FindFirstChild(tool.Name) then
                        allow = false
                    end
                end
            end
            if allow then
                DB = true
                button.BrickColor = BrickColor.new("Black")
                for i, tool in pairs(toolstorage) do
                    local newtool = tool:clone()
                    newtool.Parent = player.Backpack
                end
                wait(2)
                button.BrickColor = startcolor
                DB = false
            end
        end
    end
end)
0
thanks for the reply but where do i put the script where this code is supposed to go? ffdg199 1 — 5y
0
The script I posted would be put into a part, that when clicked would give the player the item listed in another folder ref as "Tools" ABK2017 406 — 5y
Ad

Answer this question