Problems with footprint system

Hello! Im new to scripting and Im creating an invisible obby with footprint system. (This is an repost)

I already have a working system in the game that creates semitrasparent parts while player is walking, but it doesnt work as i want it to do. So, I need some help in customising it. I will explain everything detailed as possible.

What do I want to achieve, exactly? Thats what i need:

  • Footprint parts, spawned by local player, being visible only for this player by default.
  • Footprint parts changing their color by pressing specific GUI button. Again, color change will apply for local players footprints only.
  • All of the players’ footprints would be visible for local player through gamepass.

How does it work now?

  • Footprints of all players are visible for everyone.
  • If player changes footprint color through GUI button, it applies for everyones footprints too.

How does the system work? All of the scripts i think are related to the question are given at the end of the topic.
Main system script is a module script. Its being required by its parent, server script. This script is located in ServerScriptService. Script also has a child, config, where some values, including Color3Value for parts color, are stored. I have a GUI with some color of footprints, and when the button is pressed, it fires an RemoteEvent to the another script inside ServerScriptService that changes the value of Color3Value.
In picture the ierarchy looks like this:
Снимок экрана (59)

What solutions have i tried this far?

  • Changing requiring script to local - it didnt work at all.
  • Replacing Footprint color value to Starter Player - it didnt change anything.
  • Replacing Footprint color value to StarterPlayerScripts - it gives me an error.
  • Looking for an answer in devforum - nothing.

If you didnt understand something, or something i forgot to mention, ask me - Ill give more information. Hope someone solves this. Again, Im new to scripting, so please explain as clear as possible. Any help would be appreciated.

Scripts:

FootprintColtroller (yes, this is an toolbox script… so i do not know how the most of this system works. oops. also u can find here my tries of changing paths.)

local module = {}

function module.startController(Character,FootPrintConfiguration,filteredMaterials)
	local walking = false
	local feet = nil
	local footType = ""
	if Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
		feet = {Character.LeftFoot,Character.RightFoot}
		footType = "Flat"
	else
		if Character:FindFirstChild("Left Leg") then
			feet = {Character["Left Leg"],Character["Right Leg"]}
			footType = "Extended"
		else
			feet = {Character.LeftFoot,Character.RightFoot}
			footType = "Flat"
		end
	end
	Character.Humanoid.Running:Connect(function(speed)
		if speed > 0 and not Character.Humanoid.Jump and Character.Humanoid.FloorMaterial ~= "Air" then
			walking = true
		else
			walking = false
			for i,v in pairs(feet) do
				for i,v in pairs(v:GetChildren()) do
					if script.Effects:FindFirstChild(v.Name) then
						v.Enabled = false
					end
				end
			end
		end
	end)
	local currentFoot = nil
	local function det()
		if currentFoot == nil then
			currentFoot = "Right"
		else
			if currentFoot == "Right" then
				currentFoot = "Left"
			else
				currentFoot = "Right"
			end
		end
	end
	local raycastParams = RaycastParams.new()
	raycastParams.FilterDescendantsInstances = {Character}
	raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
	local function addPrint(useSize,part,pos)
		det()
		local print_ = Instance.new("Part")
		print_.Anchored = true
		
		local foot = nil
		
		if Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
			foot = Character:FindFirstChild(currentFoot.."Foot")
		else
			if Character:FindFirstChild("Left Leg") then
				foot = Character:FindFirstChild(currentFoot.." Leg")
			else
				foot = Character:FindFirstChild(currentFoot.."Foot")
			end
		end
		
		print_.Transparency = FootPrintConfiguration.FootPrintTransparency.Value
		print_.CanCollide = false
		print_.Material = Enum.Material.SmoothPlastic
		
		if FootPrintConfiguration.UsePartColor.Value then
			if part.Color then
				print_.Color = part.Color
			end
		else
			print_.Color = game.ServerScriptService.Footprints.FootprintConfiguration.FootprintColor.Value
			--print_.Color = game:GetService("Players").LocalPlayer.PlayerScripts.FootprintColor.Value
		end
		
		if FootPrintConfiguration.UseEffects.Value then
			local effect = script.Effects:FindFirstChild(Character.Humanoid.FloorMaterial.Name)
			if effect then
				for i,v in pairs(feet) do
					if not v:FindFirstChild(effect.Name) then
						effect = effect:Clone()
						effect.Parent = v
					else
						v:FindFirstChild(effect.Name).Enabled = true
					end
				end
			else
				for i,v in pairs(feet) do
					for i,v in pairs(v:GetChildren()) do
						if script.Effects:FindFirstChild(v.Name) then
							if v.Enabled then
								v.Enabled = false
							end
						end
					end
				end
			end
		end
		
		if not useSize then
			print_.Size = Vector3.new(1, 0.09, 1)
		else
			if footType == "Flat" then
				print_.Size = Vector3.new(foot.Size.X,foot.Size.Y/2,foot.Size.Z)
			elseif footType == "Extended" then
				print_.Size = Vector3.new(foot.Size.X,foot.Size.Y/8,foot.Size.Z)
			else
				print("Invalid Foot Type")
				script:Destroy()
				return
			end
		end
		print_.CFrame = CFrame.new(pos) * CFrame.Angles(0, math.rad(foot.Orientation.Y), math.rad(180))
		print_.Parent = game.Workspace.GlobalFootPrints
		local Tween = game:GetService("TweenService"):Create(print_,TweenInfo.new(FootPrintConfiguration.FadeTime.Value/Character.Humanoid.WalkSpeed*game.StarterPlayer.CharacterWalkSpeed),{Transparency=1})
		Tween:Play()
		Tween.Completed:Connect(function()
			print_:Destroy()
		end)
	end
	
	-- main
	det()
	
	local printDB = false
	game:GetService("RunService").Heartbeat:Connect(function()
		if walking and not printDB then
			local foot = nil
			if Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
				foot = Character:FindFirstChild(currentFoot.."Foot")
			else
				if Character:FindFirstChild("Left Leg") then
					foot = Character:FindFirstChild(currentFoot.." Leg")
				else
					foot = Character:FindFirstChild(currentFoot.."Foot")
				end
			end
			local ray = Ray.new(foot.Position, Vector3.new(0, -2, 0),raycastParams)
			if workspace:FindPartOnRay(ray) then
				if not FootPrintConfiguration.FilteredMaterials.Value then
					printDB = true
					local p,p1 = workspace:FindPartOnRayWithIgnoreList(ray,{Character,game.Workspace.GlobalFootPrints})
					addPrint(FootPrintConfiguration.UseFootSize.Value,p,p1)
					wait(FootPrintConfiguration.PrintsPerSecond.Value)
					printDB = false
				else
					if table.find(filteredMaterials,Character:FindFirstChild("Humanoid").FloorMaterial.Name) then
						printDB = true
						local p,p1 = workspace:FindPartOnRayWithIgnoreList(ray,{Character,game.Workspace.GlobalFootPrints})
						addPrint(FootPrintConfiguration.UseFootSize.Value,p,p1)
						wait(FootPrintConfiguration.PrintsPerSecond.Value)
						printDB = false
					else
						for i,v in pairs(feet) do
							for i,v in pairs(v:GetChildren()) do
								if script.Effects:FindFirstChild(v.Name) then
									if v.Enabled then
										v.Enabled = false
									end
								end
							end
						end
					end
				end
			end
		end
	end)
end

return module

Footprints (script that requires the module)

local GlobalFootPrints = Instance.new("Folder")
GlobalFootPrints.Name = "GlobalFootPrints"
GlobalFootPrints.Parent = workspace

local filteredMaterials = {"Sand"}

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(chr)
		local FootPrintController = require(script.FootprintController)
		FootPrintController.startController(chr,script.FootprintConfiguration,filteredMaterials)
	end)
end)
warn("Loaded Global FootPrints [VER:"..script.Version.Value.."]")

On server event script

game:GetService("ReplicatedStorage").ColorChange.OnServerEvent:Connect(function(plr, color)
	
	game.ServerScriptService.Footprints.FootprintConfiguration.FootprintColor.Value = color
	--game:GetService("Players").LocalPlayer.PlayerScripts.FootprintColor.Value = color
	game.StarterPack.BP.ColorValue.Value = color
	
end)
1 Like

Local Scripts will change things for the Client only.

Move the things you want just the Client to see to a Local Script. Don’t use Remote Events to update things on the Server and only the Client will see the changes.

1 Like

So, Ive found a solution for the system not working in StarterPlayerScripts. I changed requiring script to this:

local GlobalFootPrints = Instance.new("Folder")
GlobalFootPrints.Name = "GlobalFootPrints"
GlobalFootPrints.Parent = workspace

local filteredMaterials = {"Sand"}

repeat wait() until game.Players.LocalPlayer.Character

--game.Players.PlayerAdded:Connect(function(plr)
	--plr.CharacterAdded:Connect(function(chr)
		--print("Chr added")
		--local FootPrintController = require(script.FootprintController)
		--FootPrintController.startController(chr,script.FootprintConfiguration,filteredMaterials)
	--end)
--end)

local FootPrintController = require(script.FootprintController)
FootPrintController.startController(game.Players.LocalPlayer.Character,script.FootprintConfiguration,filteredMaterials)


warn("Loaded Global FootPrints [VER:"..script.Version.Value.."]")

And it works pretty fine. Moreover, It works even better and doesnt lag as it did before!

But changing color still doesnt work for some reason.

Ive found out about BindableEvent and used it instead of RemoteEvent, but it didnt work. I keep getting this error:

Unable to assign property Value. Color3 expected, got nil

What have I done wrong?

Scripts related to color change that Ive changed:

game:GetService("ReplicatedStorage").ColorChange.Event:Connect(function(plr, color)
	
	script.Parent.Footprints.FootprintConfiguration.FootprintColor.Value = color
	--game:GetService("Players").LocalPlayer.PlayerScripts.FootprintColor.Value = color
	game.StarterPack.BP.ColorValue.Value = color
	
end)

Script in the GUI button:

local button = script.Parent
local color = button.BackgroundColor3

button.Activated:Connect(function()
	
	game:GetService("ReplicatedStorage").ColorChange:Fire(color)
	
end)

Module scpirt part related to color change:

print_.Color = script.Parent.FootprintConfiguration.FootprintColor.Value

Bindable Events only work when sending info between matching types of scripts:

LOCAL to LOCAL = Bindable
SERVER to SERVER = Bindable

LOCAL to SERVER = Remote
SERVER to LOCAL = Remote

Your ColorChange is located in ReplicatedStorage. I’m guessing that means your using a BindableEvent to try and communicate between a LOCAL and SERVER script. It won’t work. Use a RemoteEvent instead.

1 Like

I am communicating between local script (gui button script) and another local script (color changing script located in StarterPlayerScripts). What can cause the problem?

Something you are gathering is not being gathered.

Use print commands in each script, Module script included to figure out which script is not gathering the info:

local button = script.Parent
local color = button.BackgroundColor3

button.Activated:Connect(function()
	game:GetService("ReplicatedStorage").ColorChange:Fire(color)
	print(color) -- print the things you are gathering and see where they are nil
end)
1 Like

With your method, i found out that line …Event:Connect(function(plr, color) contains an error. I removed “plr” from function and now everything works as expected. Thank you!

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