Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

It appears that Its not giving kills when you kill someone with a AK-47, why?

So I made a tool with a GUI Inside It which Is used to keep on track on how many kills you currently have, to get kills you must kill someone with a AK-47, Currently there is a problem where It won't give me kills even If you kill someone with the AK-47, there Is a error that says:

TextLabel Is not a valid member of ScreenGUI "Players.imnotaguest1121 (Thats my username).PlayerGUI.ScreenGUI

Local script (Shows GUI and bugged/glitch give kills):

wait(1)
GUI = script.Parent.ScreenGui
local Player = game.Players.LocalPlayer
local Kills = 1

script.Parent.Equipped:Connect(function()
	local GUIClone = GUI:Clone()
	GUIClone.Parent = Player.PlayerGui
	script.Parent.Unequipped:Connect(function()
		GUIClone:Destroy()
	end)
	script.Parent.GiveKill.OnClientEvent:Connect(function() ---Used a RemoteEvent
		Kills = Kills + 1
		GUIClone.TextLabel = "Kills: "..Kills
	end)
end)

And If you want, the server script: (Look at Line 22):

local tool = script.Parent
local Shoot = tool.Shooting
local PewAnimation = tool.Animation

tool.Fire.OnServerEvent:Connect(function(player,mousePos)
	local Humanoid = tool.Parent.Humanoid

	local AnimationTrack = Humanoid:LoadAnimation(PewAnimation)
	AnimationTrack:Play()
	Shoot:Play()
	local raycastParams = RaycastParams:new()
	raycastParams.FilterDescendantsInstances = {player.Character}
	raycastParams.FilterType = Enum.RaycastFilterType.Blacklist

	local raycastResault = workspace:Raycast(tool.Handle.Position,(mousePos - tool.Handle.Position)*1000,raycastParams)
	if raycastResault then
		local hitpart = raycastResault.Instance
		local model = hitpart:FindFirstAncestorOfClass("Model")
		if model then
			if model:FindFirstChild("Humanoid") then
				model.Humanoid.Health -= math.random(1,2)
				if model.Humanoid.Health <= 1 then
					tool.GiveKill:FireClient(player)
				end
			end
		end
	end
end)

1 answer

you're parenting the cloned GUI object to Player.PlayerGui but the error message tells me you're looking for it in Player.PlayerGui.ScreenGui

btw a line number for the error would be super helpful

3 comments

0

I think the numberline Is 06:28:36.399, I saw the number In outpost

0

like, which line of code the error came from

0

it should say "stack begin [line break] script '[the path to the script in question]', Line [the line number]

This discussion is preserved as it was. New answers, comments, and votes are closed.