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

Tried to make baseplate CanCollide true on my client, doesn't work?

game.Players.PlayerAdded:Connect(function(plr)
	local ownerKey = 316061618
	local id = plr.UserId
	if id == ownerKey then 
		local clone = game.ReplicatedStorage.baseplateEditScript:Clone()
		clone.Parent = plr.Character
	end
end)

I tried to make a script that checks the UserId of a player that is added to the world. If the player has the ownerKey as their Id (which is my Id), it'll create a LocalScript that makes the baseplate's CanCollide set to true, and sets the LocalScript's Parent to the player's character.

Here's the LocalScript's code:

local base = game.Workspace.Baseplate

base.CanCollide = true 

I was thinking that this LocalScript would only make the baseplate CanCollide on my client, not to the whole server. When I played on the world, I fell through the baseplate (meaning CanCollide was still false). Does anyone know how to fix this so that my client can have the baseplate collidable, but have everyone else's client remain CanCollide to false?

2 answers

✓ Accepted answer

First Create an event in

game.ReplicatedStorage

named BaseRemover

Server Script

local BaseRemover = game.ReplicatedStorage.BaseRemover
game.Players.PlayerAdded:Connect(function(Player)
	if Player.UserId == 316061618 then
		BaseRemover:FireClient(Player)
	end
end)

Local Script

game.ReplicatedStorage.BaseRemover.OnClientEvent:Connect(function()
	game.Workspace.Baseplate.CanCollide = true
end)

4 comments

0

Did not work, even when changing the LocalScript's name to "BaseRemover". It would have also made CanCollide false instead of true, and also some of the code doesnt make sense to me, so please explain it.

0

did u make an event

0

idk how. Is an event just a script causing something to happen. srry if its obvious

0

A remote event

Hello, all you would need is one local script in StarterCharacterScripts to check the UserID and set the baseplate accordingly.

--// Services
local Players = game:GetService("Players")

--// Player vars
local player = Players.LocalPlayer
local ownerID = 316061618

--//Physical
local char = player.Character or player.CharacterAdded:wait()
local baseplate = workspace:WaitForChild("Baseplate")

--// If the IDs match then change the Collisions making it so only you won't fall through
if player.UserId == ownerID then
	baseplate.CanCollide = true
end

EDIT:

--// Services
-- This wouldn't get changed because it's the player service 
local Players = game:GetService("Players")

--// Player vars
local plr = Players.LocalPlayer -- Change to "plr" here
local ownerID = 316061618

--//Physical
local char = plr.Character or plr.CharacterAdded:wait() -- Change to "plr" here
local baseplate = workspace:WaitForChild("Baseplate")

--// If the IDs match then change the Collisions making it so only you won't fall through
if plr.UserId == ownerID then -- Change to "plr" here
	baseplate.CanCollide = true
end

3 comments

0

One thing I saw is that you overwrote the value of Players on line 2, and also I changed that to "plr" and it still told me line 9 gave a nil value.

0

The value on line 2 is the Players service it would be the same as doing game.Players.LocalPlayer to get the player. If you really want to change it to "plr" I'll edit the code but the "Players" variable should be left alone.

0

I edited it but did you try just following the code and instructions without touching anything to see it worked?

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