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

"Trying to call Method on object of type: 'Vector3' with incorrect arguements." Help please?

The script is this:

fout = false
function touched(part)
	if fout == false then
	local flag = game.ServerStorage.Flag:Clone()
	flag.Parent = workspace
	workspace.Flag.CanCollide = true
	flag.Position = part.Parent.Head.Position + Vector3.new(0,13,0)
	flag.Anchored = false
	flag.Orientation = part.Parent.Head.Orientation + Vector3.new(0,90,90)
	fout = true
local weld = Instance.new('Weld')
	weld.Part0 = part.Parent.HumanoidRootPart
	weld.C0 = part.Parent.Head.CFrame:inverse()
	weld.Part1 = game.Workspace.Flag
	weld.C1 = game.Workspace.Flag.CFrame:inverse()
	weld.Parent = game.Workspace.Flag
	end
end

workspace.FlagGiver.Touched:Connect(touched)


Inside the flag:

function GFlag(part)
	workspace.Flag:Destroy()
	local NFlag = game.ServerStorage.Flag:Clone()
	NFlag.Orientation = part.Parent.Head.Orientation(0,90,90)
	NFlag.Position = part.Parent.Head.Position + Vector3(0,13,0)
local weld = Instance.new('Weld')
	weld.Part0 = part.Parent.HumanoidRootPart
	weld.C0 = part.Parent.Head.CFrame:inverse()
	weld.Part1 = game.Workspace.Flag
	weld.C1 = game.Workspace.Flag.CFrame:inverse()
	weld.Parent = game.Workspace.Flag
end

workspace.Flag.Touched:Connect(GFlag)

The purpose of the first script is to summon a flag above the players head upon touching a brick, the purpose of the second script is to allow anyone who touches the flag to steal it.

The first runs fine, however when touching the second flag it is destroyed then this message appears in the output:

19:58:37.362 - Trying to call method on object of type: Vector3 with incorrect arguments. 19:58:37.362 - Stack Begin 19:58:37.363 - Script 'Workspace.Flag.Script', Line 4 19:58:37.363 - Stack End

I can't work out what I've done wrong, help?

1 answer

I don't think you used orientation correctly on line 4 inside the flag. There's 2 ways to fix this :

You can either try this on line 4 :

NFlag.Orientation = Vector3.new(0,90,90) --This rotates the part

or this on line 4 :

NFlag.Orientation = part.Parent.Head.Orientation --This rotates the part based on the head's orientation.

2 comments

0

My god I feel dumb now, I was for some reason trying to correct line 5, thinking that one was wrong. Thanks! :)

0

No problem. :D

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