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:
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)