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

Why Doesn't the Player Climb the Truss?

I'm trying to create a game with Splatoon-like mechanics, and the swimming in ink works fine but when it comes to wall climbing it isn't working. What I originally tried was using velocity but it flopped so instead I opted to use invisible trusses that become collide-able if the its color is the same as the players. However the character usually goes to the edge of the wall rather than going up.

Squid Movement:

local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent.Parent)
local character = script.Parent.Parent.Parent
local speed = 5
local weld = script.Parent.Weld
local squid = script.Parent.Parent

script.Parent.Touched:connect(function(hit)
	if hit.Name == "InkablePart" or "InkableWall" then
		if hit.Name == "InkablePart" then
			if hit.Color == script.Parent.Color then
				speed = 30
			else
				speed = 5
			end
		end
		if hit.Name == "InkableWall" or hit.Parent.Name == "InkableWall" then
			if hit.Name == "InkableWall" then
				if hit.Color == script.Parent.Color then
					speed = 15
					for i,v in pairs(hit:GetChildren()) do
						v.CanCollide = true
					end
				else
					speed = 5
					for i,v in pairs(hit:GetChildren()) do
						v.CanCollide = false
					end
				end
			else
				if hit.Parent.Color == script.Parent.Color then
					speed = 15
					for i,v in pairs(hit.Parent:GetChildren()) do
						v.CanCollide = true
					end
				else
					speed = 5
					for i,v in pairs(hit.Parent:GetChildren()) do
						v.CanCollide = false
					end
				end
			end
		end
	else
		for i,v in pairs(workspace:GetChildren()) do
			if v.Name == "InkableWall" then
				for i,v in pairs(v:GetChildren()) do
					v.CanCollide = false
				end
			end
		end
		speed = 5
	end
end)

while true do
	if speed == 30 then
		weld.C0 = CFrame.new(0,3,0) * CFrame.Angles(0,math.rad(180),0)
	elseif speed == 5 then
		weld.C0 = CFrame.new(0,2.25,0) * CFrame.Angles(0,math.rad(180),0)
	elseif speed == 15 then
		for i,v in pairs(squid:GetChildren()) do
			if v:IsA('Part') or v:IsA('UnionOperation') then
				v.Transparency = 1
			end
		end
		repeat wait() until speed ~= 15
		for i,v in pairs(squid:GetChildren()) do
			if v:IsA('Part') or v:IsA('UnionOperation') then
				v.Transparency = 0
			end
		end
	end
	character.Humanoid.WalkSpeed = speed
	wait()
end

To make the squid the characters body parts and hats and stuff are made invisible and then the squid is welded to the humanoidrootpart with an offset so it appears like it's swimming.

1 answer

###The error is on line 8.

if hit.Name == "InkablePart" or "InkableWall" then

###This is a common mistake. You see, when you use or, you must specify what the second thing is. This is your if statement without your hit.Name == "InkablePart" or bit.

if "InkableWall" then

###What does this line mean?? If string then what? Is it this?

if script.Parent.Text == "InkableWall" then

###Is it the Text of a TextBox? Is it the Value of a StringValue? You have to specify what the condition is, else it returns false.

#To fix this error:

if hit.Name == "InkablePart" or hit.Name == "InkableWall" then

###We specified what the string "InkableWall" belonged to. It belonged to the Name.

On a side note, switch to Connect, as ROBLOX may remove connect soon.

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