So I’m trying to make a gun and if you shoot it makes a gui showing the damage. The problem is that the gui is not showing. I checked the difference between a gui in workspace and in server storage and they’re both the same. I don’t know what happened There’s no error in the output, so I don’t know what to fix. Here’s my code:
local billboard = Instance.new("BillboardGui")
billboard.Parent = game.ServerStorage
local label = Instance.new("TextLabel")
label.Parent = billboard
label.BackgroundTransparency = 1
label.Font = Enum.Font.Oswald
label.TextColor3 = Color3.new(0.986053, 0, 0.0271153)
label.TextSize = 50
label.Visible = true
label.TextStrokeTransparency = 0
local bullets = 5
local reload = false
local config = script.Parent.Configuration
script.Parent.Equipped:Connect(function(mouse)
mouse.Button1Down:Connect(function()
if bullets > 1 then
if reload == false then
local part = mouse.Target
local hum = part.Parent:FindFirstChild("Humanoid")
if hum then
if part.Name == "Head" then
hum.Health -= config.Headshot.Value
billboard.Parent = part.Parent --Temp
billboard.Adornee = part.Parent.Head --Temp
billboard.AlwaysOnTop = true
label.Text = tostring(config.Headshot.Value) --Temp
print("HEADSHOT")
bullets -= 1
elseif part.Name ~= "Head" then
hum.Health -= config.NormalShot.Value
billboard.Parent = part.Parent --Temp
billboard.Adornee = part.Parent.Head --Temp
billboard.AlwaysOnTop = true --Temp
label.Text = tostring(config.Headshot.Value) --Temp
print("Successful Shot")
bullets -= 1
end
end
end
The rest is just gun reloading. Also don’t mind the temp comments.
I would greatly appreciate it if you could help me. Thanks
I get what you mean, and I used a remote event and did all the reparenting and stuff there, but when reparenting in the server script, it says attempt to index string with 'Parent'. Both parent and billboard arguments i set in the tuple are the instances. Here’s what I’ve got on the local script that I changed:
local Adornee = part.Parent.Head
local AlwaysOnTop = true
local ZIndex = 1
local Text = tostring(config.Headshot.Value)
game.ReplicatedStorage.GunGUI:FireServer(part.Parent.Head, Adornee, AlwaysOnTop, ZIndex, Text, billboard, label)
and the server script (which I put in server script service):
game.ReplicatedStorage.GunGUI.OnServerEvent:Connect(function(parent, adornee, alwaysontop, zindex, text, billboard, label)
billboard.Parent = parent --This is where I get the error
billboard.Adornee = adornee
billboard.AlwaysOnTop = alwaysontop
label.ZIndex = zindex
label.Text = text
end)
EDIT: After a little searching I found that the billboard GUI instance in the tuple mysteriously was converted into a string.
Alright now I have another problem:
The billboard instance becomes a string
I tried giving the path to the billboard instance but it still returns a string.
EDIT: Everything important has gone wrong. The text turns to 1 when it should be the headshot damage value, and the adornee is the model itself and not the head.
EDIT 2: I checked the types of everything I input in the tuple and everything is messed up