Hey so I made this script that should the units stats when the unit is clicked but it doesnt show the gui.
Heres the script
local function showUnitInfo()
print("showUnitInfo triggered")
if selectedUnit then
mainGui.Selection.Visible = true
local configuration = selectedUnit.Configuration
mainGui.Selection.Stats.Damage.Value.Text = configuration.Damage.Value
mainGui.Selection.Stats.Range.Value.Text = configuration.Range.Value
mainGui.Selection.Stats.Cooldown.Value.Text = configuration.Cooldown.Value
mainGui.Selection.Title.UnitName.Text = selectedUnit.Name
mainGui.Selection.Title.ImageLabel.Image = configuration.Image.Texture
end
end
1 Like
Is this the full script? If so you didn’t call the function.
Add this under whereever you want to call it from:
showUnitInfo()
yea I called the function here
userInputService.InputBegan:Connect(function(input, processed)
if processed then
return
end
if unitCanSpawn then
if input.UserInputType == Enum.UserInputType.MouseButton1 then
if canPlace then
placeUnitEvent:FireServer(unitCanSpawn.Name, unitCanSpawn.PrimaryPart.CFrame)
placedUnits += 1
inventoryandhotbarsui.Units.Text = "Units: " .. placedUnits .. "/" .. maxUnits
removePlacedUnits()
invalidPlacementMessage.Visible = false
else
invalidPlacementMessage.Visible = true
invalidPlacementMessage.TextTransparency = 0
fadeOutMessage()
end
elseif input.KeyCode == Enum.KeyCode.R then
rotation += 90
end
elseif hoveredValue and input.UserInputType == Enum.UserInputType.MouseButton1 then
local model = hoveredValue:FindFirstAncestorOfClass("Model")
if model and model.Parent == workspace.Units then
selectedUnit = model
else
selectedUnit = nil
end
showUnitInfo()
end
end)
1 Like
After i called it, it still didnt work
1 Like
yea it still didnt work i dont know why theres no errors in output.
1 Like