Making a shadow script.


  • So if you've ever watched skateboarding, you'll see stuff like this:

    0_1485723523010_upload-38a47812-6bc3-451c-8a8d-5e1f8c8626be

    I tried making this in ROBLOX, but I ran into a ton of problems. Basically, I want to clone a shadowed version of their character ever second or so where the character was, showing where they've been. This sounds simple, and I thought it was.

    The problem I ran into was the inability to make the cloned parts can-collide false.

    Here is my script:

    --// Services
    local Players = game:GetService("Players")
    
    --// Code
    Players.PlayerAdded:Connect(function(plr)
    	plr.CharacterAdded:Connect(function(char)
    		repeat
    			wait()
    		until((char)and(char.Parent))
    		wait(0.5)
    		while(char.Parent)do
    			--print(char)
    			local clone = Instance.new("Model")
    			clone.Parent = workspace
    			for _,child in next, char:GetChildren() do
    				if(not((child:IsA("Script"))or(child:IsA("LocalScript")or(child.Name=="HumanoidRootPart"))))then
    					local childClone = child:Clone()
    					print(childClone)
    					childClone.Parent = clone
    					if(child:IsA("BasePart"))then
    						child.Transparency = 0.8
    						child.Anchored = true
    						child.CanCollide = false
    					end
    				end
    			end
    			wait(1)
    			--clone:Destroy()
    		end
    	end)
    end)
    

    This is more of a, "try this so I know it's harder than it sounds", type thing.

    I think you get the idea.

    If you could try this, I would be thankful :cookie:

    :3


  • alt text

    the bad code

    -- services
    local debris = game:GetService('Debris')
    
    -- vars
    local cachedModels = {}
    local plrFolder = Instance.new('Folder')
    plrFolder.Name = 'Players'
    plrFolder.Parent = game.Workspace
    
    local thingsToRemove = {
    	['Motor6D'] = true,
    	['Sound'] = true,
    	['LocalScript'] = true,
    	['StringValue'] = true,
    	['Animation'] = true,
    	['Script'] = true,
    	['Humanoid'] = true,
    }
    local function rmThings(itm)
    	local function run(obj)
    		for _, ins in pairs(obj:GetChildren()) do		
    				
    			if thingsToRemove[ins.ClassName] then
    				ins:Destroy()
    			end
    			
    			if ins then
    				if ins:IsA('BasePart') then				
    					ins.Anchored = true 
    					ins.CanCollide = false
    				end		
    				run(ins)
    			end
    		end
    	end
    	run(itm)
    	return itm
    end
    
    local function addModel(charModel)
    	if cachedModels[charModel.Name] then return end
    	
    	charModel.Archivable = true
    	local tmp = charModel:Clone()
    	charModel.Archivable = false
    	
    	cachedModels[charModel.Name] = rmThings(tmp)
    end
    
    local function setCFrame(model, plrModel)
    	for _, v in pairs(plrModel:GetChildren()) do
    		if v:IsA('BasePart') and model[v.Name] then
    			model[v.Name].CFrame = v.CFrame
    		end
    		for _, v2 in pairs(v:GetChildren()) do
    			if v2:IsA('BasePart') and model[v.Name][v2.Name] then
    				model[v.Name][v2.Name].CFrame = v2.CFrame
    			end
    		end
    	end
    end
    
    game.Players.PlayerAdded:Connect(function(plr)
    	local folder = Instance.new('Folder')
    	folder.Name = plr.Name	
    	folder.Parent = plrFolder
    	
    	plr.CharacterAppearanceLoaded:Connect(function(charModel)
    		addModel(charModel)
    	end)
    end)
    
    game.Players.PlayerRemoving:Connect(function(plr)
    	cachedModels[plr.Name] = nil
    	if plrFolder[plr.Name] then plrFolder[plr.Name]:Destroy() end
    end)
    
    while wait(0.1) do
    	for _, plr in pairs(game.Players:GetPlayers()) do
    		if plr.Character and cachedModels[plr.Name] then
    			local tmp = cachedModels[plr.Name]:Clone()
    			setCFrame(tmp, plr.Character)
    			delay(0.1, function()
    				tmp.Parent = plrFolder[plr.Name]
    			delay(3,function() tmp:Destroy() end)
    			end)
    		end
    	end
    end
    

  • @kingdom5 Do you think there might be a way to get the image of the clothing and add it as a decal or something?

    I mean, just wondering.


  • @OldPalHappy I don't think this is possible its just a limitation of roblox.


  • @kingdom5 Gosh darn it.


  • It's definitely possible to clone the clothing with it.
    All the parts, the shirt and the pants should all be cloned into a model which contains a humanoid. Add the model to Debris for 3 seconds or continue to use the delay.


  • @Vrakos The problem is you collide with the models if they have a Humanoid.


  • You could always make a custom control script that can move you through solid objects.

Log in to reply
 

Looks like your connection to Scripting Helpers was lost, please wait while we try to reconnect.