Trouble making a throw system

anyone knows how to fix this or suggest better alternatives for the scripts?

local player = game:GetService("Players").LocalPlayer

local RS = game:GetService("ReplicatedStorage")
local SS = game:GetService("ServerStorage")

local ragdollevent = RS:WaitForChild("RagdollPlayer")

local newblocks = SS:WaitForChild("ThrowingBlocks"):GetChildren() 

local throwevent = RS:WaitForChild("ThrownBlock")

local newblock

throwevent.OnServerEvent:Connect(function(player: Player ,holdingblockpos: Part, force, mousehit: Vector3)

	
	if holdingblockpos.Parent == "GreenCube" and holdingblockpos.Parent:IsA("Tool") then
		newblock = newblocks[1]:Clone()
		
	elseif  holdingblockpos.Parent == "BlueCube" and holdingblockpos.Parent:IsA("Tool") then
		newblock = newblocks[2]:Clone()
		
	elseif holdingblockpos.Parent == "RedCube" and holdingblockpos.Parent:IsA("Tool") then
		newblock = newblocks[3]:Clone()
		
	end

	

	newblock.Parent = workspace

	newblock.Position = holdingblockpos.Position + Vector3.new(0, 1, 1)

	newblock:ApplyImpulse(mousehit * force)
	
end)

few mistake here n there mb

When you check for holdingblockpos’s parent, you’re checking if the parent equals to a string, which you can’t because a parent must be an Instance, you need to check for the parent’s name instead.

2 Likes

this helped thanks :sweat_smile:, theres alot i dont know

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