Attempt to call instance value on line 21!?

server script inside of serverscriptservice

game.ReplicatedStorage.M1Fired.OnServerEvent:Connect(function(player)
	local muchacho = require(game.ServerStorage.MuchachoHitbox)
	local hitbox = muchacho.CreateHitbox()
	local owner = (player.Name)
	local didhit = false
	game.Workspace:FindFirstChild(owner).Humanoid.WalkSpeed = 0
	game.Workspace:FindFirstChild(owner).Humanoid.JumpPower = 0
	hitbox.Size = Vector3.new(5, 5, 6)
	hitbox.Transparency = 0.8
	hitbox.Color = Color3.fromRGB(147, 0, 2)
	hitbox.CanCollide = false
	hitbox.Anchored = true
	hitbox.Parent = workspace
	hitbox.CFrame = player.Character.HumanoidRootPart.CFrame
	hitbox.Offset = CFrame.new(0, 0, -3)
	hitbox:Start()
	hitbox.Touched:Connect(function(hum, hit)
		if hit.Parent.Name ~= owner and didhit == false then
			didhit = true
			if hit.Parent.Humanoid then
				if game.Workspace(owner):FindFirstChild("didthefinalhitofcombo").Value == false then
					hit.Parent.Humanoid:TakeDamage(3)
					hit.Parent:FindFirstChild("stuntime").Value = 0.35
				if game.Workspace(owner):FindFirstChild("didthefinalhitofcombo").Value == true then
					hit.Parent.Humanoid:TakeDamage(4)
					hit.Parent:FindFirstChild("stuntime").Value = 0.5
					hit.Parent:Destroy()
				end
			else
				print("could not find humanoid")
			end
		end
	end)
	task.wait(0.1)
	game.Workspace:FindFirstChild(owner).Humanoid.WalkSpeed = 10
	game.Workspace:FindFirstChild(owner).Humanoid.JumpPower = 50
	hitbox:Destroy()
end)

Local script inside of tool (i know its repetitive, but i am going to add animations.

local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local m1count = 0
local m1cooldown = false
local full_m1cooldown = false

local function onInputBegan(input, gameProcessedEvent)
	if not gameProcessedEvent and m1cooldown == false and input.UserInputType == Enum.UserInputType.MouseButton1 and script.Parent.Parent.Parent == workspace then
		if script.Parent.Parent.stuntime.Value <= 0 then
			if m1count == 0 then
				m1cooldown = true
				m1count += 1
				game.ReplicatedStorage.M1Fired:FireServer(player)
				wait(0.3)
				m1cooldown = false
			elseif m1count == 1 then
				m1cooldown = true
				m1count += 1
				game.ReplicatedStorage.M1Fired:FireServer(player)
				wait(0.3)
				m1cooldown = false
			elseif m1count == 2 then
				m1cooldown = true
				m1count += 1
				game.ReplicatedStorage.M1Fired:FireServer(player)
				wait(0.3)
				m1cooldown = false
			elseif m1count == 3 then
				m1cooldown = true
				m1count += 1
				game.ReplicatedStorage.M1Fired:FireServer(player)
				wait(0.3)
				m1cooldown = false
			elseif m1count == 4 then
				script.Parent.Parent.didthefinalhitofcombo = true
				m1cooldown = true
				m1count += 1
				game.ReplicatedStorage.M1Fired:FireServer(player)
				wait(0.3)
				m1cooldown = false
				script.Parent.Parent.didthefinalhitofcombo = false
			elseif m1count >= 5 and full_m1cooldown == false then
				full_m1cooldown = true
				wait(2)
				m1count = 0
				full_m1cooldown = false
			end
		elseif script.Parent.Parent.stuntime.Value > 0 then
			print("ur stunned !")
		end
	end
end

UIS.InputBegan:Connect(onInputBegan)


im a beginner at scripting, so excuse the messiness.
on line 21 it says attempt to call instance value and this is the only method i could think of for checking when the player finishes their m1 combo.

  • any feedback helps, im trying to get better!
2 Likes

Workspace is an instance, you can’t call it like that. (Like the error says) Are you trying to get the character of owner? You could do this (based on what it looked like you were doing)
game.Workspace:FindFirstChild(owner, true):FindFirstChild("didthefinalhitofcombo")
You could also do
player.Character:FindFirstChild("didthefinalhitofcombo")

1 Like

THANK YOU SO MUCH IT WORKS!!! but then in the local script in the tool it says that didthefinalhitofcombo is not a valid member of the player.

Can you say what line? The codes kind of long…

line 37, the line right below elseif m1count == 4 then

Assuming this is right underneath the tool, I think you parented it wrong?
script<tool<backpack<player<player(s)
If your looking to make sure it’s specifically “didthefinalhitofcombo”, I’d check
“if player.UserId == [userid here] then”, which I believe you got from the serverfiring

its in the right places because it says its unable to find it in the players character but it is there. Sorry if i confused you by saying player but didthefinalhitofcombo is part of the character, and i dont know why it cant find it even though it is there.

nvm, fixed it lol!!!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.